immyy

New Member
Joined
Jul 8, 2014
Messages
3
I was wondering how - if possible - I can go about using the autofill method to fill to the end of the column if the column isn't necessarily specified, but referenced. It's harder to explain than it is to see so here's what I'm working with right now. I just started using VBA a couple of months ago and I'm self taught, so please feel free to correct any common mistakes or unnecessary bits of code.

Code:
'find start column and insert 1 column after
    Set findcol = Worksheets(2).Rows(1).Find(What:="Tribeca", LookIn:=xlValues)
    Dim FindColNum As Long
    FindColNum = findcol.Column + 1
    Columns(FindColNum).Insert shift:=xlToRight
    
    'identify which IDs already exist and bring in correlating system ID
    Columns(FindColNum).Cells(1, 1).Value = "SF ID"
    Columns(FindColNum).Cells(2, 1).Formula = "=vlookup(a2,sfv,11,0)"
    Columns(FindColNum).Cells(2, 1).AutoFill Destination:=Range("need help with this part" & Range("a" & Rows.Count).End(xlUp).Row)

I've used this method of autofilling in several of my other macros but in all of them it's a static range. I need to be able to search the first row for a string, and work off of that column's location.

I also toyed with the idea of using a count of the rows as the autofill destination but I'm still unsure of how to write that into the autofill method.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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