problem in selection of ranges in macro

harshab6

Active Member
Joined
Oct 1, 2008
Messages
254
Hi Experts,
I have got the macro coding that consolidates the sheet which is named as time sheet .I use the following coding below and it works well.
Sub timesheet ()
Dim ws As Worksheet, wsOut As Worksheet, sName As String
sName = "Time Sheet"
Set wsOut = Worksheets.Add(after:=Sheets(Sheets.Count))
For Each ws In Worksheets
If UCase(ws.Name) Like UCase(sName) & "*" Then
zz = ws.Range("N" & Rows.Count).End(xlUp).Row
zz = Application.Max(zz, 4)
ws.Range("A4:A2000", ws.Range("N" & zz)).Copy wsOut.Range("A" & Rows.Count).End(xlUp)(2)
End If
Next ws
End Sub
.but now the entire format of time sheet has been changed and below code need to be Added to macro In order work perfectly
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Which selects the range as per above code and copies and consolidates the sheet.I am really confused where to make the necessary changes tried several times but unable to get appropriate result. I want the macro to follow same earlier procedures but only the selection ranges need to be changed
Thanks for the help
Harsha
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Code:
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select 
Range(Selection, Selection.End(xlToRight)).Select
By this, do you mean?
Code:
Range(Range("A4"), Range("A4").End(xlDown)).Select
Too much selection isn't likely to be useful for the code, the user, and just about all else.
 
Upvote 0
Hi,
thanks for the quick reply.yes thats what I need.But I need to select down and right (End(xlToRight)).Select)but I cannot figure out where to add this code in my previous macro.please can you put some light on it.
 
Upvote 0
I want the macro to follow same earlier procedures but only the selection ranges need to be changed
I don't see anything selected in the original macro.

Perhaps if you clarify just what you want changed, and to what, then maybe ...
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top