Referencing Ranges on other Sheets

  • Thread starter Thread starter MatthewByrne
  • Start date Start date
M

MatthewByrne

Hi, I have an issue with a function I'm working on at the moment. I hav
the following code:


Dim thisRange As Range

thisRange = Range(firstCell, lastCell)


The problem is that I need to reference this range on one workshee
from another. I've tried:


Dim thisRange As Range
Dim dataSheet As String

dataSheet = "Data"
thisRange = Worksheets(dataSheet).Range(firstCell, lastCell)


Thanks,
Matthe
 
Hi
nearly there. Try
sub foo()
dim target_wks as worksheet
dim rng as range
Dim dataSheet As String

dataSheet = "Data"

set target_wks = worksheets(dataSheet)
set rng = target_wks.range("A1:B20")
end sub
 
What are FirstCell and LastCell. Are they ranges, strings?

If strings, what isthe problem you are having.

firstCell = "A1"
LastCell = "H9"
? worksheets("sheet2").Range(FirstCell,LastCell).Address(external:=True)
[Listbox_MoveUp.xls]Sheet2!$A$1:$H$9
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top