How to resolve VB Script issues tween diff versions of Excel

Joined
May 8, 2003
Messages
29
Hello Folks,

I have a large database with lots of macros that I have set up for a user (tied to buttons). I am using Excel 2000, Win NT. The user has Excel 97, Win 98. There are 2 problems that I am having. They are:

1) The buttons are not showing up on the users machine; and

2) The macros are not working the exact same between the different versions. It ends up cutting out half way through the macro. The macro in question is as follows:

Code:
Sub Entered()

    Dim printer_warning
    printer_warning = MsgBox("Please make sure the Printer is turned ON and there is paper loaded." & vbCr & Space(10) & "If the Printer is ON and there is paper loaded, Click OK..." & vbCr & Space(35) & "Otherwise click CANCEL", vbExclamation + vbOKCancel + vbDefaultButton1, Space(40) & "WARNING!")
        ' If user selects Cancel then stop macro and return to the spreadsheet
        If warning = vbCancel Then Exit Sub
        
' Filter database to show only records that were entered today
    Rows("6:6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.AutoFilter
    ActiveWindow.ScrollColumn = 252
    Selection.AutoFilter Field:=255, Criteria1:=Format(Now(), "dd/mm/yyyy")
    
    ' Hide Columns
    Columns("D:M").Select
    Selection.EntireColumn.Hidden = True
    Columns("P:R").Select
    Selection.EntireColumn.Hidden = True
    Columns("U:IV").Select
    Selection.EntireColumn.Hidden = True
    
    ' Hide Rows
    Rows("1:5").Select
    Selection.EntireRow.Hidden = True
    
    Application.ScreenUpdating = False
    
    ' Start at Cell A8 and Select all Rows down with Data in them
    Range(Range("A8"), Range("A" & Rows.Count).End(xlUp)).EntireRow.Select
        
    ' Sort by Cell B8 (Last Name) and then by C8 (First Name)
    Selection.Sort Key1:=Range("B8"), Order1:=xlAscending, Key2:=Range("C8"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    
    ' Start at Cell A8 and Select all Rows down with Data in them
    Range(Range("A6"), Range("A" & Rows.Count).End(xlUp)).EntireRow.Select
    Range(Selection, Selection.End(xlDown)).Select
    
    With ActiveSheet.PageSetup
    ' Set Print Area
        .PrintArea = ""
    
    ' Printing Parameters
    
    ' Prints Rows 6 & 7 as the Title Row
    .PrintTitleRows = Rows("6:7").Address
    
    ' Print a Custom Header in the Center
    .CenterHeader = "Clients Entered on &D"
    
    ' Print a Custom Footer ... File Name on the left & Print Date & Time on the right
    .LeftFooter = "&F"
    .RightFooter = "Printed &D at &T"
    .LeftMargin = Application.InchesToPoints(0)
    .RightMargin = Application.InchesToPoints(0)
    .TopMargin = Application.InchesToPoints(0.78740157480315)
    .BottomMargin = Application.InchesToPoints(0.78740157480315)
    .HeaderMargin = Application.InchesToPoints(0.511811023622047)
    .FooterMargin = Application.InchesToPoints(0.511811023622047)
    .PrintHeadings = False
    .PrintGridlines = False
    .Orientation = xlLandscape
    .PaperSize = xlPaperLetter
    .CenterHorizontally = True
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    End With
    
    ActiveSheet.PrintOut Copies:=1, Collate:=True
    
    ' "Turns off" the Custom Header
    ActiveSheet.PageSetup.CenterHeader = ""
    
    ' Turn AutoFilter OFF
    Selection.AutoFilter
    
    ' Un-Hide Columns
    Cells.Select
    Selection.EntireColumn.Hidden = False
    
    ' Un-Hide Rows
    Rows("1:5").Select
    Selection.EntireRow.Hidden = False
    
    Range("B8").Select
 
    Application.ScreenUpdating = True

End Sub

If more info is needed please let me know.

Any comments and / or help are always appreciated.

Thanks,
Loki
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Re: How to resolve VB Script issues tween diff versions of E

Don't know about the different versions, but shouldn't there be a FALSE after the selection.autofilter near the end of the macro?

Calicat
 
Upvote 0
Re: How to resolve VB Script issues tween diff versions of E

Hmmm, well the macro works fine without the FALSE using Excel 2000, but maybe that is what is causing the probs in the lower versions...

I will check it out. Thanks for the info Cali.

Any ideas as to why the buttons wouldn't appear in Excel 97? They sorta blink quickly (meaning you can see em for a short bit), then they disappear. I've never seen this kind of behaviour before. :confused:
 
Upvote 0
Re: How to resolve VB Script issues tween diff versions of E

Ok, I added the FALSE to it and when I ran the macro it gave me a Run-time error '1004': Unable to set the AutoFilter property of the Range class.

So back to having no FALSE in there. Thanks for the try though, I do appreciate it.
 
Upvote 0
Re: How to resolve VB Script issues tween diff versions of E

It hung on the Filtering part of the code, and there was no error code. It just "hung".

From a suggestion from an un-related post I have modified the coding a bit. I will run it again tonight at the users place and see what comes of it. I will post the results as soon as i can.

And the buttons ... well, they just blip once and disappear for some reason. Almost as if they have been set to "hidden" (when this is not the case).

Thanks in advance,
Loki
 
Upvote 0
Re: How to resolve VB Script issues tween diff versions of E

My only other suggestion is to STEP thru your code. This will pinpoint the line of code that is the issue. In the VBA editor, under toolbars.
 
Upvote 0
Re: How to resolve VB Script issues tween diff versions of E

Ok, the changes I made to the coding resolved the hang ups. The coding works fine now (on all 3 versions of Excel I have tested it on ... XP, NT & 97). :)

HOWEVER, I am STILL experiencing the problem with the buttons not displaying. As indicated earlier, they display for a split second and the disappear, leaving 1 gray button shape with no text, etc...

It is almost as if there is an "on load ... hide" function at work. :confused:

Any ideas?
 
Upvote 0

Forum statistics

Threads
1,216,747
Messages
6,132,486
Members
449,729
Latest member
davelevnt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top