[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-09-12
2
Medium Priority
?
300 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

829 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