Hello,
I have existing code below that puts the left, mid and right formula in their respective columns on Sheet1.
Sub test()
Dim I As Integer
Dim M As Integer
Dim P As Integer
Dim ws As Worksheets
Set wsT = Sheets("Sheet1")
lastrow = wsT.Cells(Rows.Count, 2).End(xlUp).Row ' 2 = column B
For I = 7 To lastrow ' 7 = Column G where I want my results to be for the left formula
For M = 8 To lastrow ' 8 = Column H where I want my results to be for the mid formula
For P = 9 To lastrow ' 9 = Column I where I want my results to be for the right formula
'LEFT
wsT.Cells(I, 7).Value = Left(wsT.Cells(I, 2))
'MID
wsT.Cells(I, 8).Value = Mid(wsT.Cells(I, 6, 3))
'RIGHT
wsT.Cells(I, 9).Value = Right(wsT.Cells(I, 2))
Next I
End Sub
However, when I hit the button to run the code I get this error, "Compile error: Argument not optional".
What I want to do is loop this code and perform the formulas for all 3 sheets when I press the button. Any ideas? Thx
Bookmarks