+ Reply to Thread
Results 1 to 4 of 4

Easy question - If ...then Change cell value

  1. #1
    Mike R.
    Guest

    Easy question - If ...then Change cell value

    Greetings,
    This seems like such an easy question, but I have searched and just cannot
    find the answer.

    In my Workbook Open(), I would like to check the value of Q1 and if it = 1,
    then change the value to = 2.

    I have tried:
    If Range("Q39").Value = "1" Then
    Range("Q39").Value = "2"
    End If

    But it errors out... help...
    Mike

  2. #2
    KL
    Guest

    Re: Easy question - If ...then Change cell value

    Hi Mike,

    Your code works fine to me. If anything I would change the "1" and "2" to 1
    and 2 and qualify the range with the sheet name, something like this:

    Private Sub Workbook_Open()
    With Sheets("Sheet1")
    If .Range("Q39").Value = 1 Then
    .Range("Q39").Value = 2
    End If
    End With
    End Sub

    Regards,
    KL


    "Mike R." <[email protected]> wrote in message
    news:[email protected]...
    > Greetings,
    > This seems like such an easy question, but I have searched and just cannot
    > find the answer.
    >
    > In my Workbook Open(), I would like to check the value of Q1 and if it =
    > 1,
    > then change the value to = 2.
    >
    > I have tried:
    > If Range("Q39").Value = "1" Then
    > Range("Q39").Value = "2"
    > End If
    >
    > But it errors out... help...
    > Mike




  3. #3
    Karthik Bhat - Bangalore
    Guest

    Re: Easy question - If ...then Change cell value

    Hi
    Buddy your code is fine but the cell reference in it is wrong. It
    should be "Q1" and not "Q39".

    If Range("Q1").Value = "1" Then
    Range("Q1").Value = "2"
    End If


    Thanks
    Karthik Bhat
    Bangalore


  4. #4
    William Benson
    Guest

    Re: Easy question - If ...then Change cell value

    It should not be erring out, something else is up with that! Nor should it
    matter whether you have quotes around the "1" and "2" as far as I can tell
    .... and the fact that you have mixed up Q1 and Q39 seems like an obvious
    typo that even if not what you meant, should not be generating an error, it
    should just behave in ways you were not desiring,

    Bill
    "Mike R." <[email protected]> wrote in message
    news:[email protected]...
    > Greetings,
    > This seems like such an easy question, but I have searched and just cannot
    > find the answer.
    >
    > In my Workbook Open(), I would like to check the value of Q1 and if it =
    > 1,
    > then change the value to = 2.
    >
    > I have tried:
    > If Range("Q39").Value = "1" Then
    > Range("Q39").Value = "2"
    > End If
    >
    > But it errors out... help...
    > Mike




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1