SYTAX problems

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

Below is a code that I am trying to use to select a
range. The range can constantly change so it must be
dynamic. The code I used below pops up red when entered
and I cannot figure out how to make it work. Can anyone
please help? There are numbers in cells K1 AND L1. Lets
say the number in cell K1 is 5 and the number in cell L1
is 10. If this was the case the code would need to
reference these cells to select the range. In this
instance it would select A5:G10.

Range("Sheets("Resolutions").Range ("A" & Range
("K1").Value): Sheets("Resolutions").Range("G" & Range
("L1").Value)").Select

Todd Huttenstine
 
Hi Todd
try
sub foo()
dim rng as range
dim val_1
dim val_2

val_1 = activesheet.range("K1").value
val_2 = activesheet.range("L1").value
set rng = range("A" & val_1 & ":G" & val_2)
rng.select
end sub
 
Todd

Try this one.
Notice the dots, which makes sure, that all
ranges are from the mentioned sheet.

Sub test()
Dim DummyRange As Range

With Sheets("Resolutions")
Set DummyRange = Range(.Range("A" & .Range("K1").Value), _
.Range("G" & .Range("L1").Value))
.Select
End With

DummyRange.Select

End Sub
 
Thank you both. Very nice. Totally different approaches
than what I was thinking.

Todd
 

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