+ Reply to Thread
Results 1 to 33 of 33

Coding Multiple Cases in VBA

Hybrid View

  1. #1
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Coding Multiple Cases in VBA

    Just add a line like at the end

    Range("Chart").PrintOut Copies:=1
    Uses a name range called Chart

    http://www.contextures.com/xlNames01.html

    As my profile says....London

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  2. #2
    Registered User
    Join Date
    11-18-2005
    Posts
    17

    Re: Coding Multiple Cases in VBA

    I am using the code from your post #23

    When you say put it at the end, where exactly do you mean?

    I put it at the very end...went to debugger
    I put it just before End Sub ... went to debugger

    Not real sure where to insert the PRINT command for "Charts"

    Thanks

    BillofSoo

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Coding Multiple Cases in VBA

    Do you name the range to print?

    VBA Noob

  4. #4
    Registered User
    Join Date
    11-18-2005
    Posts
    17

    Re: Coding Multiple Cases in VBA

    VBA Noob
    This is the code I am using to print the various arrays based on the criterion >50

    Sub Test()
    Dim ArrRng As Variant
    Dim ArrPrint As Variant
    Dim i As Long
        ArrRng = Array("J28", "J38", "J50", "J61", "J73", "J93")
        ArrPrint = Array("S100:U161", "S163:U188", "S190:U218", "S220:U269", "S271:U313", "S315:U382")
    For i = 0 To UBound(ArrRng)
        With Range(ArrRng(i))
            If IsNumeric(.Value) Then
                If .Value > 50 Then
                    With ActiveSheet
                        .Range(ArrPrint(i)).PrintOut Copies:=1
                    End With
                End If
            End If
        End With
        
    Next i
    End Sub

    The code below is the code you wrote me last night and told me to put it at the "end" of the above code.(it is the module code you wrote in post #23 on this forum and it works fine).

    Code:
    Range("Chart").PrintOut Copies:=1Uses
    I tried to just tag it to the end of the code you previsously wrote but it just causes errors.

    The range of the data on the Worksheet called "CHART" is B3:H40.

    Where exactly do I insert this line into the code?

    I feel a bit stupid but I'm new to this.

    Would you mind telling me exactly where to insert the code to print the range B3:H40 from the worksheet "Chart"?

    Thanks,

    BillofSoo

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Coding Multiple Cases in VBA

    Code can go before or after the loop code. So let's put it at the end

    e.g

    Next i
    SubRange("Chart").PrintOut Copies:=1
    End
    Note it won't work unless you have named the ranges as I've mentioned 3 times now. Link explains how to do that

    VBA Noob

  6. #6
    Registered User
    Join Date
    11-18-2005
    Posts
    17

    Re: Coding Multiple Cases in VBA

    Hi VBA Noob

    Are you there?

    BillofSoo

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Coding Multiple Cases in VBA

    Hi VBA Noob

    Are you there?

    BillofSoo
    How did you get on?

    VBA Noob

+ 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