Solved

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

Posted on 2011-09-12
2
291 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:Mswetsky
2 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 36524213
dim aVar as range and then set aVar to the activecell via

set aVar = activecell

Chris
0
 
LVL 1

Author Closing Comment

by:Mswetsky
ID: 36524358
Thanks, for you quick & simple to understand answer
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now