+ Reply to Thread
Results 1 to 33 of 33

Coding Multiple Cases in VBA

Hybrid View

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

    Re: Coding Multiple Cases in VBA

    Thanks VBA Noob

    I have stripped out the info from the worksheet - left some in as well along with some notes so you don't have to work hard to figure out how I set this up. I included three modules you have seen and adjusted them to match my exact cell/array locations.

    Best of luck...hope you get this.

    Best regards,

    BillofSoo
    Attached Files Attached Files

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

    The missed changing one range address

    ArrRng = Array("K28", "J38", "J50", "J61", "J73", "J93")
    Is that you're problem?

    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 !!!

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

    Re: Coding Multiple Cases in VBA

    VBA Noob

    I know what the problem is....in the cells that are tested >50, I have formulas!!! you have just numbers. When I put straight numbers in column K and adjust the module to accommodate, this code works as it is supposed to.

    How can I get the value obtained through the formula to appear in another cell as a value only?

    That will solve the problem.

    BillofSoo

  4. #4
    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

    Maybe this amend code which won't require the cler_print module

    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", "S164:U188", "S192:U218", "S224:U269", "S276:U313", "S321: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
    VBA Noob

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

    Re: Coding Multiple Cases in VBA

    VBA Noob:

    This works beautifully. Is it possible to add one more thing?

    I would like the same module to print a worksheet in the same workbook named "Chart". The worksheet is already i formatted for Print Area....

    The cells I want to print in "Chart" are B3:H40

    If you get a minute, this would be the "icing on the cake"!!

    Thanks VBA Noob...you have been most helpful. If you don't mind, on your next post, can you tell me where (country/state) you are located??? I am suspecting England; but I may well be out to lunch on that.

    Anyway, will await your reply.

    Best regards and thanks again!

    BillofSoo

  6. #6
    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

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

+ 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