Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default referring to workbook

I have a sub that searches for blanks and removes them. however someone
helped me with the code and i do not know how to write it so that it works
for any workbook. In the code below a specific workbook is used but if I save
the file under different name it does not work. how do you write the code so
that it refers to the current workbook that is open?


Public Sub findAndRemoveBlanks()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng, rCell As Range

Set WB = Workbooks("20060619c")
Set SH = WB.Sheets("Indata")
Set rng = SH.UsedRange
'Set rng = SH.Range("A1:p100")
For Each rCell In rng.Cells
With rCell
If Not IsEmpty(.Value) Then
If Not UCase(.Value) Like "*[A-Z]*" Then
.Replace What:=" ", Replacement:=""
End If
End If
End With
Next rCell

End Sub
Reply
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
referring to previous worksheet in workbook Freida Excel Worksheet Functions 9 September 29th 09 09:33 PM
referring to workbook comparini3000 Excel Programming 0 June 21st 06 05:34 PM
referring to workbook Jim Thomlinson Excel Programming 0 June 21st 06 05:34 PM
Referring to a worsheet in another workbook Roundy Excel Programming 1 June 9th 06 04:04 AM
Referring to function in another workbook psp Excel Worksheet Functions 1 August 31st 05 10:32 PM


All times are GMT +1. The time now is 02:08 PM.

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

About Us

"It's about Microsoft Excel"