Link to home
Start Free TrialLog in
Avatar of Mitch Swetsky
Mitch SwetskyFlag for United States of America

asked on

How can I get the range of the activecell and assign it to a varable

I need to revisit the same cell later in my sub but am having a hard time setting a var = activecell
I want to navigate to the first blank col then run vlookup from other open sheet and go back to active cell and fill down to the last row.
Code below is just a snip of my project.
Sheets("Actual & Flexed Workload").Activate 
 lastRow = Range("A" & Rows.Count).End(xlUp).Row  'Get last row to fill down
     Range("B3").Select          'Get consistent begin cell
    ' Most likely will be january and each month I will get new month column
     
     Selection.End(xlToRight).Select    'move to end of row to add new month data in that col
     ActiveCell.Offset(0, 1).Select
    ' I need to get this cell range and save as rngFound so after getting data from another sheet I can come back and paste in this column
  
'Poor effort of catching active cell
 AFWrow = ActiveCell.Row
 AFWcol = ActiveCell.Column
 rngFound = Range("R" & AFWrow & "C" AFWcol ")
   
 ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-8],P01Currentmonth.csv!R1C24:R +lastRow+ C29,6,FALSE)"

    Windows("2011 U.S. Financial Plan.xls").Activate
    rngFound.Select
    
    Selection.AutoFill Destination:=Range(rngFound)
    Range(rngFound).Select

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mitch Swetsky

ASKER

Thanks, for you quick & simple to understand answer