Append table data.

k209310

Active Member
Joined
Aug 12, 2002
Messages
382
I have a macro which retrieves data from a database and places it in an excel spreadsheet. At present the data is added to row 14 and overwrites any existing data.

Is there anyway possible to place the data in the first empty row instead of overwriting existing data.
As an example I am using this code at present.

Dim X As Integer
X = 14
xlSht.Range("A" & X) = rst!IWO
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
66,115
Office Version
  1. 365
Platform
  1. Windows
Try this code. In a nutshell, it goes to the bottom of the column and works its way up until it funds data. From there, you want to go down one row and paste your new data.

Range("A65536").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = rst!IWO
 

Forum statistics

Threads
1,181,580
Messages
5,930,720
Members
436,757
Latest member
Marijn

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
Top