Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Simple Macro Question

  1. #1
    Guest

    Default

    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. #2
    Guest

    Default

    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. #3
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •