Hi Rain,
You should endeavour to avoid select constructs. It is almost always
possible to avoid selects and this tends to result in shorter, more
efficient code.
A problem with your code is that, it is possible to copy bidirectionally to
a hidden sheet, it is not possible to select such a sheet.
An additional problem reside in the syntax tadopted for the paste method:
whilst the use of the destination argument is optional, if it is not used
then a selection is required. This will fail for a hidden sheet.
Therefore, removing selects, adding yje destination argument etc, you will
have code something like:
Sub Macro1(strSheet As String)
If strSheet = "Select Car" Then
Sheets(strSheet).Columns(strcol).Copy
ActiveSheet.Paste Destination:= _
Sheets("Sheet2").Range("A1")
End If
End Sub
---
Regards,
Norman
"Rain" wrote in message
...
Hi Norman,
It seems to fail on just selecting the hidden sheet. I'm selecting the
sheet before pasting data on it so that I can format the data and do some
math on it.
Code excerpt:
----------------
Sub Macro1(strSheet As String)
If strSheet = "Select Car" Then
Sheets(strSheet).Select
Columns(strCol).Select
Selection.Copy
Range("A1").Select
*** Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
Columns("B:B").Select
..
..
..
End Sub
The error that I get is:
Run-time error '1004': Select method of Worksheet class failed
TIA
"Norman Jones" wrote:
Hi Rain,
There should normally be no problem formatting cells or hiding /
unhiding
rows or columns on a hidden sheet.
If you post your code or a portion thereof which fails, perhaps more
constructive help can be offered
---
Regards,
Norman
"Rain" wrote in message
...
Hi,
I am writing an application using Excel + VBA. I am doing a lot of
calculation on data on one of the worksheets and I wish to have this
sheet
hidden. While calculating, I also format some of the columns and delete
some
columns.
It seems like Excel dosen't like this sheet to be hidden. Any reason?
Or
should I do something else?
TIA
|