Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2002
    Location
    CT
    Posts
    361
    Thanks
    0
    Thanked 1 Time in 1 Post

    Macro help (Excel XP)

    Hi all,

    A little help please with the following situation. I have a macro that prints a given number of labels based upon a quantity number in cell C34 (see below). You all helped me set up this macro several months ago.

    Now I found that when I do an occasional process it effects cell C34. In these instances cell C34 is no longer a number, but rather will contain text. As such, my macro stops and the de###### opens because it the macro is looking for a number in C34 and text is there instead.

    I need to add some code that will make the macro skip printing the label (Label 2) when text is present. Here is the current code:



    If InStr(LCase(Range("C32")), "layer") = 0 And Range("C34") > 0 Then

    ' The following prints Label 2

    Range("AR94:AW98").Select
    Application.ActivePrinter = "DYMO LabelWriter 400 on Ne06:"
    Selection.PrintOut Copies:=Range("C34"), ActivePrinter:= _
    "DYMO LabelWriter 400 on Ne06:", Collate:=True
    Application.ActivePrinter = "Brother MFC-8440 USB on Ne08:"



    Application.ActivePrinter = "Brother MFC-8440 USB on Ne08:"
    With ActiveSheet.PageSetup
    .PrintTitleRows = ""
    .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = "$A$1:$R$60"
    With ActiveSheet.PageSetup

    End With
    End If



    My thought was to add something to the IF statement in the first line:

    If InStr(LCase(Range("C32")), "layer") = 0 And Range("C34") > 0 Then

    that would make it skip the printing lines if text is present in C34. IE, something like: AND ("C34") ,"any text") = 0
    (I'm sure that is wrong, but I just want to show you what I have in mind.)

    Any ideas?

    Thanks,
    BH Davis

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro help (Excel XP)

    You can use the IsNumeric function to test whether C34 contains a valid number:

    If InStr(LCase(Range("C32")), "layer") = 0 And Range("C34") > 0 And IsNumeric(Range("C34")) Then

  3. #3
    3 Star Lounger
    Join Date
    Jan 2002
    Location
    CT
    Posts
    361
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro help (Excel XP)

    Thanks Hans.........as always you're solution is right there almost instantaneously !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Most appreciated.
    BH

Posting Permissions

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