![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#3 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|