Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    VBA syntax question (Excel XP SR1)

    In the following excerpt, which value is actually changed in the code?

    Is mo_number changed to match what's in dateval, or is it the other way around?

    <pre>Sub ChangeToThisMonth()
    Dim cRow As Integer
    Dim cCol As Integer
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Sheets("Main").Activate
    Range("mo_number").Value = Range("dateval").Value</pre>

    - Ricky

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: VBA syntax question (Excel XP SR1)

    Ricky,

    Looks like the value in dateval is being assigned to mo_number. This should be easy to verify unless there are some other factors not include in the snippet you posted.

    What does happen when the code is run ?

    Andrew C

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VBA syntax question (Excel XP SR1)

    Actually, can't run the code yet - I'm borrowing snippets from the project we did last year. I just wasn't sure which side of the "=" was being manipulated in the code.

    Here is the whole bit:

    <pre>Sub ChangeToThisMonth()
    Dim cRow As Integer
    Dim cCol As Integer
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Sheets("Main").Activate
    Range("mo_number").Value = Range("dateval").Value
    Range("a1").Select
    For i = 10 To 15
    For J = 4 To 10
    If Cells(i, J).Value = Range("Today").Value Then
    cRow = i
    cCol = J
    End If
    Next
    Next
    Cells(cRow, cCol).Select
    Sheets("Main").Select
    Range("ChosenDate") = ActiveCell.Value
    Application.ScreenUpdating = True
    Application.EnableEvents = True

    End Sub </pre>

    - Ricky

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: VBA syntax question (Excel XP SR1)

    The value in Range("dateval") is being assigned to Range("mo_number"), i.e. the left hand side is being manipulated.

    Andrew

Posting Permissions

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