ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   need a macro select all cells in a worksheet? (https://www.excelbanter.com/excel-discussion-misc-queries/95591-re-need-macro-select-all-cells-worksheet.html)

MarkN

need a macro select all cells in a worksheet?
 
Hi Russ,

Your recorded line
Range("A1:AO297").Select
will select that range all the time.

If you want to select a dynamic range, select cell A1 and use the keyboard
press Ctrl and the * (this is Ctrl Shift 8 on the keyboard). If you record
this command, it will select the active range around A1.

--
Hope this helps,
MarkN


"Russ Tarafdar" wrote:

I am new to using macros. I have worksheet which will have different numbers
of rows of data from one month to the next. I am taking data that has been
copied from a browse of the main frame and need to format it to be copied
into a reconciliation worksheet.

The problem I am running into in recording the macro is that it ends up
hardcoding the range when I select all. A test macro I created for this part
of the functionality follows:

Sub test()
'
' test Macro
' Macro recorded 6/22/2006 by ABC
'

'
Columns("C:C").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Range("C1").Select
ActiveCell.FormulaR1C1 = "abc"
Columns("F:F").Select
Selection.Insert Shift:=xlToRight
Range("F1").Select
ActiveCell.FormulaR1C1 = "def"
Range("A1:AO297").Select
Range("F1").Activate
Selection.Replace What:="", Replacement:="filler", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("C2").Select
ActiveCell.FormulaR1C1 = "CODA"
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
End Sub

Please indicate which lines of code need to be deleted and where to insert
the recommended change.



All times are GMT +1. The time now is 12:37 PM.

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