Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

Dim wsjrw As Worksheet Dim wscfw As Worksheet Set wsjrw = Worksheets("PORDER") Set wscfw…

  1. User

    Dim wsjrw As Worksheet Dim wscfw As Worksheet

    Set wsjrw = Worksheets("PORDER") Set wscfw = Worksheets(Range("I2").Value)

    wscfw.Select . In this code, instead of using the static cell I2, I would like to use the active row cell in column 11

  2. Assistant

    You can replace "Range("I2").Value" with "ActiveCell.Offset(0,10).Value". This will set the value of wscfw to the worksheet whose name is in the cell in the same row as the active cell in column 11 (offset by 10 columns to the right). Here's the revised code:

    Dim wsjrw As Worksheet Dim wscfw As Worksheet

    Set wsjrw = Worksheets("PORDER") Set wscfw = Worksheets(ActiveCell.Offset(0,10).Value)

    wscfw.Select

  3. User

    Instead of using ActiveCell can we use a reference to the Active Row

  4. Assistant

    Yes, you can use a reference to the active row by combining the row number with column 11. Here's the updated code:

    Dim wsjrw As Worksheet Dim wscfw As Worksheet Dim activeRow As Long

    Set wsjrw = Worksheets("PORDER") activeRow = ActiveCell.Row Set wscfw = Worksheets(Cells(activeRow, 11).Value)

    wscfw.Select

    In this code, the variable "activeRow" gets assigned the row number of the active cell. Then, the "Set wscfw" statement uses the "Cells" function to refer to the worksheet name in column 11 of the active row.

  5. User

    how do you add a line break in a popup message

  6. Assistant

    To add a line break in a popup message box, you can use the vbNewLine constant. Here's an example:

    MsgBox "This is the first line." & vbNewLine & "This is the second line."
    

    The vbNewLine constant inserts a line break between the two strings. This will display a popup message with two lines:

    This is the first line.
    This is the second line.
    

    You can use multiple vbNewLine constants to add additional line breaks between lines of text.

  7. User

    Set wsjrw = Worksheets("PORDER") activeRow = ActiveCell.Row Set wscfw = Worksheets(Cells(activeRow, 11).Value) Set wsent = Worksheets(activeRow, 12) wsent.Value = "Sent" I am trying to change activeRow,12 to "Sent" but there is an error in my code

  8. Assistant

    It looks like you have a syntax error in the fourth line. Instead of this:

    Set wsent = Worksheets(activeRow, 12)
    

    Try this:

    Set wsent = Cells(activeRow, 12)
    

    The Worksheets function is used to get a reference to a worksheet object by name. However, in this case, you want to set the value of a cell, not the value of a worksheet object.

    By using the Cells function with the row and column numbers, you can get a reference to the cell in the active row and column 12. Then, you can set the value of that cell to "Sent" like this:

    wsent.Value = "Sent"
    

    Make these changes to your code, and it should work correctly.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.