how do i merge two macro into one ?

iffi

Board Regular
Joined
Jun 5, 2011
Messages
59
Office Version
  1. 2019
Platform
  1. Windows
Plz i want to merge below two macros into one macro code, so whenever i run that macro, both works together. Thanks

Code:
Sub Delete_Rows()
Dim i As Long
Application.ScreenUpdating = False
With ActiveSheet
    For i = 100 To 1 Step -1
        If .Cells(i, 6) = "" Or .Cells(i, 5) = "TOTAL" Then .Cells(i, 1).EntireRow.Delete
    Next i
End With
Application.ScreenUpdating = True
End Sub
Code:
Sub ConvertToNumber()

Dim LR As Long

    LR = cells(rows.Count, 2).end(xlup).Row

    Range ("C2:C" & LR).TextToColumns

End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try

Code:
Sub Delete_Convert()
Dim i As Long
Dim LR As Long
Application.ScreenUpdating = False
With ActiveSheet
    For i = 100 To 1 Step -1
        If .Cells(i, 6) = "" Or .Cells(i, 5) = "TOTAL" Then .Cells(i, 1).EntireRow.Delete
    Next i
    LR = .Cells(Rows.Count, 2).End(xlUp).Row
    .Range("C2:C" & LR).TextToColumns
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
the below code (convert text to number) is working fine for the column C only, i want to extend the range from C2 to H100 in this below code, i tried myself to edit it but failed to do so, now asking here for this, plz amend it. Thanks

Code:
Sub ConvertToNumber()

Dim LR As Long

    LR = cells(rows.Count, 2).end(xlup).Row

    Range ("C2:C" & LR).TextToColumns

End Sub
 
Upvote 0
Try

Code:
Sub ConvertToNumber()

Dim LR As Long, i As Long

LR = Cells(Rows.Count, 2).End(xlUp).Row
For i = 2 To 8

    Range(Cells(1, i), Cells(LR, i)).TextToColumns
Next i
End Sub
 
Upvote 0
the below code (convert text to number) is working fine for the column C only, i want to extend the range from C2 to H100 in this below code, i tried myself to edit it but failed to do so, now asking here for this, plz amend it. Thanks

Code:
Sub ConvertToNumber()
 
Dim LR As Long
 
    LR = cells(rows.Count, 2).end(xlup).Row
 
    Range ("C2:C" & LR).TextToColumns
 
End Sub
Here is a different approach that may work for you...

Code:
Sub ConvertToNumber()
  With Columns("C:H")
    .NumberFormat = "General"
    .Value = .Value
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,513
Messages
6,179,214
Members
452,895
Latest member
BILLING GUY

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