ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   macros errors (https://www.excelbanter.com/excel-worksheet-functions/17500-macros-errors.html)

Natalie

macros errors
 
Hi,

I am creating a spreadsheet for different people to look at, and I have
added a macro button to change the view for each group of people.

However, if it is already on the view they want, and they press it again, it
is coming up with an error. Is there anyway I can get the error to not come
up, and just ignore it that the button has been pressed?

Bob Phillips

Can we see the code, and where it errors?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Natalie" wrote in message
...
Hi,

I am creating a spreadsheet for different people to look at, and I have
added a macro button to change the view for each group of people.

However, if it is already on the view they want, and they press it again,

it
is coming up with an error. Is there anyway I can get the error to not

come
up, and just ignore it that the button has been pressed?




Natalie

It is showing Runtime error 1004.

The macro hides 5 worksheets, and if the sheets are already hidden, and the
button is pressed again this is the error that appears.

"Bob Phillips" wrote:

Can we see the code, and where it errors?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Natalie" wrote in message
...
Hi,

I am creating a spreadsheet for different people to look at, and I have
added a macro button to change the view for each group of people.

However, if it is already on the view they want, and they press it again,

it
is coming up with an error. Is there anyway I can get the error to not

come
up, and just ignore it that the button has been pressed?





Bob Phillips

Natalie,

I think you are going to have to show us the code. I entered this in the
immediate window

worksheets("Sheet1").visible = false

ran it multiple times, no problem, as I expected. No problem if I changed
False to xlSheetHidden or even xlSheetVeryHidden.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Natalie" wrote in message
...
It is showing Runtime error 1004.

The macro hides 5 worksheets, and if the sheets are already hidden, and

the
button is pressed again this is the error that appears.

"Bob Phillips" wrote:

Can we see the code, and where it errors?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Natalie" wrote in message
...
Hi,

I am creating a spreadsheet for different people to look at, and I

have
added a macro button to change the view for each group of people.

However, if it is already on the view they want, and they press it

again,
it
is coming up with an error. Is there anyway I can get the error to not

come
up, and just ignore it that the button has been pressed?







PeterAtherton

Try something like this:

Sub test()
If Worksheets("Sheet1").Visible = False Then
Worksheets("Sheet1").Visible = True
Else: Worksheets("Sheet1").Visible = False
End If
End Sub

Peter

"Natalie" wrote:

Hi,

I am creating a spreadsheet for different people to look at, and I have
added a macro button to change the view for each group of people.

However, if it is already on the view they want, and they press it again, it
is coming up with an error. Is there anyway I can get the error to not come
up, and just ignore it that the button has been pressed?


Dave Peterson

Make sure you always have at least one visible sheet.

(maybe you're trying to hide the last visible sheet.)

Natalie wrote:

It is showing Runtime error 1004.

The macro hides 5 worksheets, and if the sheets are already hidden, and the
button is pressed again this is the error that appears.

"Bob Phillips" wrote:

Can we see the code, and where it errors?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Natalie" wrote in message
...
Hi,

I am creating a spreadsheet for different people to look at, and I have
added a macro button to change the view for each group of people.

However, if it is already on the view they want, and they press it again,

it
is coming up with an error. Is there anyway I can get the error to not

come
up, and just ignore it that the button has been pressed?





--

Dave Peterson


All times are GMT +1. The time now is 07:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com