VBA: Column Select then Data Select then return to cell A1

J

James C

How do you write in VBA:-
to select a column then select the range of data held in the column (say B1)
then return to Cell a1. The data in the column can change in the workbook as
it is updated regulary, so the range of data in the column varies constantly.
There are column headings so the range in column B1 must start at B2.

Many thanks
 
M

Mike H

Hi,

It's not entirely clear what you want but maybe this which copies the used
range of column B and pastes it into A2

Sub marine()
Dim LastRow As Long
Set sHt = Sheets("Sheet1")'Change to suit
LastRow = sHt.Cells(Cells.Rows.Count, "B").End(xlUp).Row
Range("B2:B" & LastRow).Copy _
Destination:=sHt.Range("A2")
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
R

Rob

Try
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1").Select

Don't know what you want to do with the data you have selected ?
 
J

Jacob Skaria

Hi James

Do you mean selection of the range A1:Bx where x is variable.....If so try
the below

Range("A1:B" & Cells(Rows.Count, "B").End(xlUp).Row).Select
 
Top