LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find and Replace Values in Range

I'm glad you solved it, all by yourself....
A simple mod to my "something like" would have done it, as well.
BTW You do NOT need to activate the worksheet or select the special cells.

--
Don Guillett
SalesAid Software

"ThatGirlinMS" wrote in message
ups.com...

ThatGirlinMS wrote:
Don Guillett wrote:
how about something like this

for each ws in worksheets
for each c in range("a167:a450")
if c=167 and c<=450 then c.value=c-1
next c
next ws
--
Don Guillett
SalesAid Software

"ThatGirlinMS" wrote in message
oups.com...
I have a workbook with serveral sheets that has numbers formatted as
'General' throughout in varying places. The worksheets are of no
specific width or length.

I need to loop through all sheets looking for cells containing data
within a range (ex. 167 - 450) and change to numbers (ex subtract one
from the value)


any ideas? I thought there has to be a better way than looping
through
EVERY cell in EVERY sheet.

(= 167 and <= 450) = (value - 1)

Thanks!


Nope, that's not the solution to my question. I have to look at EVERY
cell in EVERY sheet. Then I have to see if the value in that cell is
between a couple of values (ex. 167 - 450) and perform an action
accordingly (ex subtract one from the value). I have a
Selection.SpecialCells(xlCellTypeConstants).Select which selects all
cells with a constant value within. Is there a way to loop through
every cell in the selection?


I solved it myself. Thank's for viewing!

Sub callme()
Application.ScreenUpdating = False
Dim sheetcnt As Integer
sheetcnt = ActiveWorkbook.Sheets.Count
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
MsgBox "Working on sheet " & ActiveSheet.Name

Selection.SpecialCells(xlCellTypeConstants).Select

Dim oCell As Range
For Each oCell In Selection
If IsNumeric(oCell.Value) Then
If oCell.Value = 167 And oCell.Value <= 450 Then
oCell.Value = (oCell.Value - 1)
oCell.Font.Bold = True
End If
If oCell.Value = 475 And oCell.Value <= 595 Then
oCell.Value = (oCell.Value + 2)
oCell.Font.Bold = True
End If
If oCell.Value = 596 And oCell.Value <= 805 Then
oCell.Value = (oCell.Value + 5)
oCell.Font.Bold = True
End If
If oCell.Value = 812 And oCell.Value <= 814 Then
oCell.Value = (oCell.Value - 1)
oCell.Font.Bold = True
End If
If oCell.Value = 815 And oCell.Value <= 819 Then
oCell.Value = (oCell.Value + 2)
oCell.Font.Bold = True
End If
End If
Next
Next
MsgBox "Done"
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
find and replace nonzero values with 1 Amylacc Excel Worksheet Functions 4 April 4th 23 10:53 AM
Find and Replace Cell Values Jeff Excel Discussion (Misc queries) 3 March 23rd 10 01:46 PM
Find and Replace looking for values ArcticWolf Excel Discussion (Misc queries) 1 November 14th 07 12:42 PM
Find replace hyperion Values [email protected] Excel Discussion (Misc queries) 3 February 20th 07 05:37 PM
Can you Find and Replace values with in a formula? rascall Excel Discussion (Misc queries) 2 June 22nd 05 11:55 PM


All times are GMT +1. The time now is 11:54 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"