VBA(EXCEL) import data from ms access

luffy88

New Member
Joined
Feb 13, 2017
Messages
8
Hello,
I have a problem with importing data from ms access to excel with VBA. I use "ADO Connection" to connect excel with acces. When I use "xlSheet.Range("A5").CopyFromRecordset rs" to import data from access db, it's works fine. But I want to skip some column in excel sheet. How can I do it? sorry im new in vba ..

my db table
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]id[/TD]
[TD]name[/TD]
[TD]date[/TD]
[TD]description[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]



my excel sheet
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]id here[/TD]
[TD]name here[/TD]
[TD]date here[/TD]
[TD]skip column[/TD]
[TD]description here[/TD]
[/TR]
[TR]
[TD]..[/TD]
[TD]..[/TD]
[TD]..[/TD]
[TD]..[/TD]
[TD]..[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Welcome to the forum!

Within your connection string, you can choose to select all (SELECT * ) and use code to insert a column (which would shift the description data to column E. You could also break things up and select id, name, date in your first copy from recordset command and repeat with selecting only the description and sending to E5.

Here's an article that explains ADO Connections in great detail:
Microsoft Access: Use ADO to Execute SQL statements
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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