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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,808
Messages
6,121,681
Members
449,048
Latest member
81jamesacct

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