Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to find and replace with criteria

I am trying to get a macro to check column C which is a list of numbers and
letters. If the number is less then 17 then change it to 1.

Example:

Original C Changed to
05 01
wt wt
63 63
16 01
12 01
33 33

Thank You,

Tom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 461
Default Macro to find and replace with criteria

Try this

Sub test()

Range("C1").Activate

Do Until IsEmpty(ActiveCell)

If ActiveCell.Value < 17 Then
ActiveCell.Value = 1
ActiveCell.Offset(1,0).Activate

Else ActiveCell.Offset(1,0).Activate

End If

Loop

End Sub

"basic" wrote:

I am trying to get a macro to check column C which is a list of numbers and
letters. If the number is less then 17 then change it to 1.

Example:

Original C Changed to
05 01
wt wt
63 63
16 01
12 01
33 33

Thank You,

Tom

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro to find and replace with criteria

Assume the data starts in C2 and numbers are stored as numbers and not text:

Sub ProcessData()
Dim rng as Range, rng1 as range
Dim cell as Range
set rng =range("C2",cells(rows.count,3).End(xlup))
on error resume next
set rng1 = rng.specialcells(xlconstants,xlNumbers)
on error goto 0
if not rng1 is nothing then
for each cell in rng1
if cell.value < 17 then
cell.value = 1
end if
next
Else
Msgbox "No numbers found"
end if
End Sub

--
Regards,
Tom Ogilvy


"basic" wrote:

I am trying to get a macro to check column C which is a list of numbers and
letters. If the number is less then 17 then change it to 1.

Example:

Original C Changed to
05 01
wt wt
63 63
16 01
12 01
33 33

Thank You,

Tom

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to find and replace with criteria

Your code worked great--thanks a lot.


"Tom Ogilvy" wrote:

Assume the data starts in C2 and numbers are stored as numbers and not text:

Sub ProcessData()
Dim rng as Range, rng1 as range
Dim cell as Range
set rng =range("C2",cells(rows.count,3).End(xlup))
on error resume next
set rng1 = rng.specialcells(xlconstants,xlNumbers)
on error goto 0
if not rng1 is nothing then
for each cell in rng1
if cell.value < 17 then
cell.value = 1
end if
next
Else
Msgbox "No numbers found"
end if
End Sub

--
Regards,
Tom Ogilvy


"basic" wrote:

I am trying to get a macro to check column C which is a list of numbers and
letters. If the number is less then 17 then change it to 1.

Example:

Original C Changed to
05 01
wt wt
63 63
16 01
12 01
33 33

Thank You,

Tom

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
Multiple Criteria Find & Replace Alfred Excel Worksheet Functions 3 October 21st 09 07:13 PM
Customized Find/Replace to Update Numbers Using Specified Criteria Cube Slave Excel Discussion (Misc queries) 4 August 17th 07 04:40 PM
Find & Replace and Find & Insert macro help needed RS Excel Programming 2 January 29th 07 07:35 AM
Macro to Find & Replace [email protected] Excel Worksheet Functions 2 September 14th 06 07:17 PM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM


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