Solved

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

Posted on 2011-09-12
2
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

739 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