Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I am using a Userform in exc

Status
Not open for further replies.

Clarkie001

IS-IT--Management
Aug 26, 2003
59
GB
Hi,

I am using a Userform in excel to run the following macro.
This works fine, however the issue arises when I make this available on our website for other users to view.

At that point I am getting a Run-Time error 1004 Method 'Sheets'of object'_Global' failed.

I dont understand why it works fine through excel locally but when published through the web site stops.

Any help would be much appreciated.

Clarkie


Sub Usage_Start()

Sheets("Create_Usage").Select
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("B2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("B1").Select

End Sub
 
Presumably, it is being opened thru IE - means that certain functionality needs slightly different syntax

Try this for a start but if it doesn't work, post back with the line it bombs on...
Sub Usage_Start()
dim lRow as long
With Sheets("Create_Usage")
.range("A2:A" & .range("A2").end(xldown).row).clearcontents
.range(cells(2,2),cells(range("B2").end(xldown).row,range("B2").end(xltoright).column)).clearcontents
end with
End Sub

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Clarkie001:

I've had some problems where the system was very finiky about resolving default references. You could also try pre-qualifying the sheets object reference with the workbook...

ThisWorkbook.Sheets("Create_Usage")

Ron
 
Hi Ron,

Pre qualifing the sheets gets me passed that first line, now it is falling down at Range("A2").select

Any ideas...


Clarkie
 
Qualify ALL lines
ThisWorkbook.Sheets("Create_Usage").range("A1").select


Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Hi xlbo,

Tried that, getting same error number, but different description - "Select Method of Range class failed".

Is there a way to qualify the range select part itself?

Clarkie
 
Have you tried my initial post ?? (Before we go down this particular line)

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Yes, I got the original message at the with sheets part.

Clarkie
 
Clarkie:

I don't understand why you can reference the sheet but not a range on the sheet!?! Like I said, finicky.

What happens when you try to do something other than select? Place these statements in your code after the sheet selection statement and watch what happens when you run it locally and from the web. Do you get the expected results?

X = ThisWorkbook.Sheets("Create_Usage").range("A2")

ThisWorkbook.Sheets("Create_Usage").range("A2") = "123"

Y = ThisWorkbook.Sheets("Create_Usage").range("A2").Address

Z = ActiveCell.Address

TheBook = Excel.Application.ActiveWorkbook.Name

TheSheet = Excel.Application.ActiveSheet.Name

WhereAmI = Excel.Application.Selection.Address

Ron
 
Hi Ron,

With that, it places the value 123 in cell "A2".
 
I have just noticed another thing, if I bring up the Macro menu using Alt+F8 and run the macros from there they run fine, but as soon as I try running them from the userform again I get the Run time error message.

Clarkie
 
Hi,

I have been able to resolve this issue by hiding the userform before the codes runs.

Thanks for all your help anyway, my fault it was just a stupid thing (always the worst).

Clarkie
 
Presumably, this is run from a button on the form ???
If this is the case, check the TakeFocusOnClick property and change it to FALSE if it is TRUE

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top