LUIS FREUND
asked on
Number format VBA to two different tabs in workbook
How can I apply this number format code to different sheets:
On "MAIN_PN" tab I have this code that works great But I need to apply it to "MAIN" tab O27:O30 as well.
Sub FixDates()
Columns("I").TextToColumns
Range("I4:J650", Cells(Rows.Count, "I").End(xlUp)).NumberForm at = "mm/dd/yy"
End Sub
On "MAIN_PN" tab I have this code that works great But I need to apply it to "MAIN" tab O27:O30 as well.
Sub FixDates()
Columns("I").TextToColumns
Range("I4:J650", Cells(Rows.Count, "I").End(xlUp)).NumberForm
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome Luis! :)
ASKER
Oh this came up......runtime error
I only get it when there is nothing in column O27:O30. There are instances that this area will not get populated at times.
C--Users-lfreund-Pictures-error.JPG
C--Users-lfreund-Pictures-vba.JPG
I only get it when there is nothing in column O27:O30. There are instances that this area will not get populated at times.
C--Users-lfreund-Pictures-error.JPG
C--Users-lfreund-Pictures-vba.JPG
Okay, try this...
Sub FixDates()
On Error Resume Next
With Sheets("MAIN_PN")
.Columns("I").TextToColumns
.Range("I4:J" & .Cells(Rows.Count, "I").End(xlUp).Row).NumberFormat = "mm/dd/yy"
End With
With Sheets("MAIN")
.Range("O27:O30").TextToColumns
.Range("O27:O30").NumberFormat = "mm/dd/yy"
End With
End Sub
ASKER