Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / June 2004

Tip: Looking for answers? Try searching our database.

syntax in exporting data to excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
munscher - 11 Jun 2004 20:36 GMT
   With objActiveWkb
       .Worksheets(1).Cells(1, 1).Value = DLookup("F2", "Election Table - Actual File Query", "RowNum = 5")
       .Worksheets(1).Cells(1, 2).Value = DLookup("F3", "Election Table - Actual File Query", "RowNum = 5")
       .Worksheets(1).Cells(1, 3).Value = DLookup("F4", "Election Table - Actual File Query", "RowNum = 5")
       .Worksheets(1).Cells(1, 4).Value = DLookup("F5", "Election Table - Actual File Query", "RowNum = 5")
   End With

The above code pulls information from a query and exports it to an excel worksheet one item at a time. After these four fields are filled, i want it to step down to the next row and fill in cells (2,1) (2,2) (2,3) and (2,4) and then onto row 3, 4, 5, etc..

Rather than copy/pasting the above code over and over and changing the row number, I want to use a loop that steps the variable NumCount  by 1 each time through the loop. This will increase the row number each time it loops around. The problem is i can't use a variable in the syntax ".Worksheets(1).Cells(NumCount, 4)" Is there a way to use a variable as shown here as opposed to explicitly giving a row number?

I have the same trouble in using the variable NumCount in the syntax at the end "RowNum = NumCount"... again it doesnt work unless i explicity use a number rather than a variable.

Any help?
munscher - 11 Jun 2004 20:43 GMT
Oops, i apologize... it was only a silly error preventing me from doing exactly as i intended. All fixed now.

>     With objActiveWkb
>         .Worksheets(1).Cells(1, 1).Value = DLookup("F2", "Election Table - Actual File Query", "RowNum = 5")
[quoted text clipped - 10 lines]
>
> Any help?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.