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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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
Hello,

Thank you for the suggestion. I tried the Macro, but I get error 400.

Thanks JR
 
Upvote 0
What line do you get the error on?
 
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,215,352
Messages
6,124,457
Members
449,161
Latest member
NHOJ

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