ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA: Column Select then Data Select then return to cell A1 (https://www.excelbanter.com/excel-discussion-misc-queries/254955-vba-column-select-then-data-select-then-return-cell-a1.html)

James C[_2_]

VBA: Column Select then Data Select then return to cell A1
 
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
--
James

Mike H

VBA: Column Select then Data Select then return to cell A1
 
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.


"James C" wrote:

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
--
James


Rob

VBA: Column Select then Data Select then return to cell A1
 
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 ?

"James C" wrote:

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
--
James


Jacob Skaria

VBA: Column Select then Data Select then return to cell A1
 
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

--
Jacob


"James C" wrote:

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
--
James



All times are GMT +1. The time now is 01:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com