Simple Macro Question

G

Guest

Guest
Hello

I was needing a macro that upon finding a cell containing text will place a word in the cell beside that cell.

For example if cell A1 contains "Blue" cell A2 should contain "Colour".

I wish to use a macro as I have existing formulas in all the cells in column b and want to override the formula with text when the above occurs.

My macro skills are not all that good. This is what I have so far:

Sub testing()
Application.ScreenUpdating = False
Range("b32:b300").Select
For Each Cell In Selection
If ActiveCell <> "" Then
ActiveCell.formulaR1C1= "exit",RefersToR1C1:=ActiveCell.Offset(0, 1)
End If
ActiveCell.Offset(1, 0).Select
Next Cell
Range("a1").Select
Application.ScreenUpdating = True
End Sub

Thankyou very much for any help.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I was able to figure out something that works sufficiently, which was:

Sub testing()
Application.ScreenUpdating = False
Range("b2:b200").Select
For Each cell In Selection
If ActiveCell <> "" Then
ActiveCell.Offset(-1, -1).Formula = "Colour"
End If
ActiveCell.Offset(1, 0).Select
Next cell
Range("a1").Select
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Nice y'all. based on what I read, I tweaked this a little:

ActiveCell.Offset(1,-1) = "Colour"


Sub testing()
Application.ScreenUpdating = False
'change the range to the appropriate one
Range("b1:b300").Select
For Each cell In Selection
If ActiveCell<> "" Then
ActiveCell.Offset(1,-1) = "Colour"
End If
ActiveCell.Offset(1, 0).Select
Next cell
Application.ScreenUpdating = True
Range("a1").Select
End Sub

Cheers, Nate
This message was edited by NateO on 2002-02-23 22:43
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top