Data into Excel references

Waqas ali

Board Regular
Joined
Nov 6, 2010
Messages
163
Dear All

how can i transfer data from access to excel in different cells references.

i want to select 500 or more than cells some single and some two than how can i transfer data to display in excel.:confused:
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
dear all,

i have stored cell references like $A$1, $B$1:$C$1. i want to run query and query result want to put in sheet cells address which i have stored in access table these are more than 5000 near to 100000.

for example i get 2000 cell references in query from table now i want to select these cells in excel sheet. can any one give me better idea.
 
Upvote 0
dear all,

i have stored cell references like $A$1, $B$1:$C$1. i want to run query and query result want to put in sheet cells address which i have stored in access table these are more than 5000 near to 100000.

for example i get 2000 cell references in query from table now i want to select these cells in excel sheet. can any one give me better idea.

Not sure how your data is like but I tested the below and it works for me. I'm using the same values in that one field to copy into those ranges (so the values will appear however many times in those range references).

You just have to cater it to how your data is set up.
IDFNameReferenceRC
1Bob$A$1
2John$B$2:$B$3
3Chris$C$6
4Dan$D$8:$F$12

<tbody>
</tbody>

Code:
 Sub ExportExcel()

Dim rst As DAO.Recordset
Dim objXL As Object 'Excel.Application
Dim xlWB As Object 'Workbook
Dim xlWS As Object 'Worksheet
Dim strSQL As String
Dim TblName As String, refRC As String
Dim x As Long


'TableName
TblName = "TableA"
'ID num
x = 1

'The row/col reference
refRC = Nz(DLookup("ReferenceRC", TblName, "ID =" & x), 0)

'SQL String creation
strSQL = "SELECT * FROM " & TblName

'create excel object and make it visible
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True

Set xlWB = objXL.workbooks.Open("filepath") 'filepath here
Set xlWS = xlWB.worksheets("sheet1") 'sheet name here

Set rst = CurrentDb.OpenRecordset(strSQL)

'Go through all recordset
    
       With rst
            Do Until .EOF
                xlWS.range(refRC).Value = rst!fname  'field name
                
                'increment variables
                x = x + 1
                'The row/col reference
                refRC = Nz(DLookup("ReferenceRC", TblName, "ID =" & x), 0)

                
                .MoveNext 'go to next record in query
                

             Loop
        End With
        
'close recordset
rst.Close
Set rst = Nothing


End Sub

There's tons of references and ways to do this so feel free to search on Google or see some more examples below.
Copy specific fields from recordset to excel specific columns - Access World Forums

https://support.microsoft.com/en-us/kb/246335
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,864
Messages
6,162,497
Members
451,770
Latest member
tsalaki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top