selecting cells

P

philipl

hi

I have need to select two columns from a spreadsheet, I don't know how
long these columns are going to be until runtime. I would like to be
able to select this at run time so I can write out to a text file.

I am able to get the last value in one column by using range and
intersect. And the other one this way too, so with this I should be
able to work out the cordinates for my selection area.

this seems a liitle long winded, does anyone else out there have a
better way of doing this?

thx
-Philip
 
H

Harald Staff

Hi Philip

See if this is of help. It does contain Intersect cose, so you may not like it.

Sub TestSelect()
Dim C As Range, R As Range
On Error Resume Next
Set C = Application.InputBox _
("Click some column headers please:", Type:=8)
If C Is Nothing Then Exit Sub
Set R = Intersect(C, ActiveSheet.UsedRange)
R.Select
MsgBox Selection.Address & " is pretty tonight."
End Sub
 
P

philipl

Harald Staff said:
Hi Philip

See if this is of help. It does contain Intersect cose, so you may not like it.

Sub TestSelect()
Dim C As Range, R As Range
On Error Resume Next
Set C = Application.InputBox _
("Click some column headers please:", Type:=8)
If C Is Nothing Then Exit Sub
Set R = Intersect(C, ActiveSheet.UsedRange)
R.Select
MsgBox Selection.Address & " is pretty tonight."
End Sub


thx, that did it at the end!
 

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

Top