PC Review


Reply
Thread Tools Rate Thread

Change a cell based on current content.

 
 
=?Utf-8?B?TWFobmlhbg==?=
Guest
Posts: n/a
 
      3rd May 2007
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 With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      3rd May 2007
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

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      3rd May 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
change current cell colour based on the value of adjacent cell on other worksheet Rits Microsoft Excel Programming 2 23rd Nov 2006 11:57 AM
how do I change the content of one cell based on another? Barry Microsoft Excel Misc 2 3rd Sep 2006 10:16 AM
Change the data in one cell based on content of another. =?Utf-8?B?QmFycnk=?= Microsoft Excel Misc 2 3rd Sep 2006 08:26 AM
How to change a Macro based on content of a cell Alex Microsoft Excel Discussion 3 15th May 2006 05:31 AM
How to change cell color based on content J144 Microsoft Excel Discussion 2 26th Mar 2006 06:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:16 AM.