Need Macro to Carry To The Last Line in Sheet

DCBUS

New Member
Joined
May 22, 2015
Messages
34
Below is the Macro I am using, but currently it only carries down to row 12. Can someone please help me modify so the Macro carries to last last line of data in the sheet. I will be using on multiple sheets in the future, so the row count may vary.

Code:
Sub Byers()'
' Byers Macro
'
' Keyboard Shortcut: Ctrl+Shift+B
'
    Range("C2:C12").Select
    Selection.NumberFormat = "0.00"
    Selection.NumberFormat = "0.0"
    Selection.NumberFormat = "0"
    Columns("D:D").Select
    Selection.Cut
    Range("G1").Select
    Selection.Insert Shift:=xlToRight
    Range("E2:E12").Select
    Application.Run "PERSONAL.XLSB!RemoveTags"
    Selection.Replace What:=" ", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Selection.Replace What:="[/n]", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Selection.Replace What:=".", Replacement:=". ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("F2:F12").Select
    Application.Run "PERSONAL.XLSB!SeparateDataBySemiColon"
    Range("H17").Select
End Sub

Thank you,
Jr
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi
Untested but try
Code:
Sub Byers() '
' Byers Macro
'
' Keyboard Shortcut: Ctrl+Shift+B
'
    Dim UsdRws As Long
    
    UsdRws = Range("C" & Rows.Count).End(xlUp).Row
    Range("C2:C" & UsdRws).Select
    Selection.NumberFormat = "0.00"
    Selection.NumberFormat = "0.0"
    Selection.NumberFormat = "0"
    Columns("D:D").Select
    Selection.Cut
    Range("G1").Select
    Selection.Insert Shift:=xlToRight
    Range("E2:E" & UsdRws).Select
    Application.Run "PERSONAL.XLSB!RemoveTags"
    Selection.Replace What:=" ", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Selection.Replace What:="[/n]", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Selection.Replace What:=".", Replacement:=". ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("F2:F" & UsdRws).Select
    Application.Run "PERSONAL.XLSB!SeparateDataBySemiColon"
    Range("H17").Select
End Sub
 
Upvote 0
Good Morning,

Thank you for the response. I rebooted the system and no longer get the error?? All seems to work, except on column "F", which on this sheet, there are 23 rows, but it only executes down to row 13.

Thank you very much,
JR
 
Upvote 0
Do all columns have the same amount of data (ie 23 rows)?
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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