Macro to fill down all cells from a vlookup on a different sheet

JadonR

Board Regular
Joined
Apr 15, 2009
Messages
154
Office Version
  1. 365
I would like to create a macro that can fill down cells A2 through C in Sheet3, based on how many rows there are in Sheet 1. For example, I have 20 rows on Sheet 1...

Sheet1.JPG


And the macro should copy down all cells in A2 through C and stop with the total of rows from Sheet1.
Sheet3.JPG


I created the basic macro below to illustrate what I want.

VBA Code:
Sheets("Sheet3").Activate
Range("A2:C2").Select
Selection[B].AutoFill Destination:=Range("A2:C20")[/B], Type:=xlFillDefault

I would like the AutoFill Destination range to match the number of rows from Sheet1 which will dynamically change when fresh data is copied into that sheet.
 
Then you can't resize by 0 (the row number from sheet1 minus 1 as your autofill data starts on row 2), and you also can't Autofill to the same row. Your Sheet1 only has a header or is blank in column A, your cells you are filling start on Row 2

That's odd, because Sheet1 contains 6156 rows of records. Why wouldn't it be seeing that? Is it because I have Column A hidden in Sheet1?
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Is it because I have Column A hidden in Sheet1?
Works fine for me with hidden column A (I just filled to row 25 in column A, hid the column and the message box returned 25), if you have filters applied to column A, it will only see the visible data (same with hidden rows).
 
Upvote 0
Do you still return a 1 with
VBA Code:
Sub testme()
MsgBox Sheets("Sheet1").Columns(1).Find("*", , xlFormulas, , xlByRows, xlPrevious).Row
End Sub
 
Upvote 0
Do you still return a 1 with
VBA Code:
Sub testme()
MsgBox Sheets("Sheet1").Columns(1).Find("*", , xlFormulas, , xlByRows, xlPrevious).Row
End Sub

I confirmed there are no filters set for Sheet1. Running your second macro also returns a message of "1".
 
Upvote 0
Then I am afraid I don't know without seeing the workbook
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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