Hi,
I had a macro where the results are placed in sheet2, if the sheet is renamed to sheet3..,sheet4...,so on the macro does not work as it is set as w1 and w2,
i need a code where the result can be stored in any sheet#, can any one please help me on this
Option Explicit
Sub GetBat()
Dim w1 As Worksheet, w2 As Worksheet
Dim c As Range, NR As Long, Sp
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
Set w2 = Worksheets("Sheet2")
NR = 0
For Each c In w1.Range("A1", w1.Range("A" & Rows.Count).End(xlUp))
NR = NR + 1
Sp = Split(c, "\")
w2.Cells(NR, 1).Value = Sp(UBound(Sp))
Next c
w2.UsedRange.Columns.AutoFit
w2.Activate
Application.ScreenUpdating = True
End Sub
Regards,
Jackgn
I had a macro where the results are placed in sheet2, if the sheet is renamed to sheet3..,sheet4...,so on the macro does not work as it is set as w1 and w2,
i need a code where the result can be stored in any sheet#, can any one please help me on this
Option Explicit
Sub GetBat()
Dim w1 As Worksheet, w2 As Worksheet
Dim c As Range, NR As Long, Sp
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
Set w2 = Worksheets("Sheet2")
NR = 0
For Each c In w1.Range("A1", w1.Range("A" & Rows.Count).End(xlUp))
NR = NR + 1
Sp = Split(c, "\")
w2.Cells(NR, 1).Value = Sp(UBound(Sp))
Next c
w2.UsedRange.Columns.AutoFit
w2.Activate
Application.ScreenUpdating = True
End Sub
Regards,
Jackgn