-
Solved: Do a .Replace on an inactive sheet
I have a routine that runs perfect as long as the sheet is selected.
I'm trying to convert this code to run so that the sheets does not have to be selected (actually I would like the sheet to be hidden).
Can this routine be changed to do this?
Thanks for any help...
JimS
[vba]
i = .Cells(.Rows.Count, "BA").End(xlUp).Row
Sheets("Data").Select
.Range("C2:C" & i).Select
For Each c In Selection
c.Value = re.Replace(c.Value, "")
Next c
For Each c In Selection
c.Value = rf.Replace(c.Value, "")
Next c
For Each c In Selection
c.Value = rg.Replace(c.Value, "")
Next c
For Each c In Selection
c.Value = rh.Replace(c.Value, "")
Next c
End With
[/vba]
-
Figured it out. I needed the following:
[VBA]
With Worksheets("Data")
i = .Cells(.Rows.Count, "BA").End(xlUp).Row
End With
With Worksheets("Data").Range("C2:C" & i)
'not sure how you want to set the range to act on
' but this is quick and easy
'Sheets("Data").Select
'.Range("C2:C" & i).Select
For Each c In Selection
c.Value = re.Replace(c.Value, "")
Next c
For Each c In Selection
c.Value = rf.Replace(c.Value, "")
Next c
For Each c In Selection
c.Value = rg.Replace(c.Value, "")
Next c
For Each c In Selection
c.Value = rh.Replace(c.Value, "")
Next c
End With
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules