LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default referencing a file name and sheet name

how can i reference the file name so that whenever i run this macro in other
file i dont have to go to and change the Worrkbook name and worksheet name. i
want it to recognize it itself because i am going to be usign the macro on
multipe excel file.

here is the code
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set WB = Workbooks("*.xls")
Set SH = WB.Sheets("VT Masterlist") '
Set rng = SH.Range("A:A")


For Each rCell In rng.Cells
With rCell
ipos = InStr(rCell.Value, ".")
If ipos 0 Then
rCell.Value = Left(rCell.Value, ipos - 1)
End If
End With

Next rCell

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"