Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Change a cell based on current content.

I have a sheet full of numbers, intermixed with other data, and need to
change certain cells based on a single criteria.

If the cell contains the character : then I need to add 0: to the beginning
of the current string in that cell.

Can anyone help me with a concise bit of code that will search one sheet and
change those selected cells?

Thank you in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Change a cell based on current content.

Sub colonate()
Dim s As String
For Each r In ActiveSheet.UsedRange
s = r.Value
If InStr(s, ":") 0 Then
r.Value = "0:" & s
End If
Next
End Sub

--
Gary''s Student - gsnu200718

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Change a cell based on current content.

Sub AAA()
Dim cell As Range
For Each cell In Selection.SpecialCells(xlConstants, xlTextValues)
Debug.Print cell.Address, cell.Text
If InStr(1, cell.Value, ":", vbTextCompare) Then
cell.Value = "'0:" & cell.Value
End If
Next
End Sub

--
Regards,
Tom Ogilvy




"Mahnian" wrote:

I have a sheet full of numbers, intermixed with other data, and need to
change certain cells based on a single criteria.

If the cell contains the character : then I need to add 0: to the beginning
of the current string in that cell.

Can anyone help me with a concise bit of code that will search one sheet and
change those selected cells?

Thank you in advance.

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
how to change a cell color based on its content using macro? Ranger888 New Users to Excel 6 December 15th 08 08:23 PM
Change row height based on content of merged cell Steve[_89_] Excel Programming 2 May 1st 07 02:32 PM
how do I change the content of one cell based on another? Barry Excel Discussion (Misc queries) 2 September 3rd 06 10:16 AM
Change the data in one cell based on content of another. Barry Excel Discussion (Misc queries) 2 September 3rd 06 08:26 AM
How do I change content of a cell based on date diving1 Excel Worksheet Functions 2 December 19th 04 08:39 PM


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