runtime error help panicking!

M

Mifty

Hi everyone,

I'm getting a runtime error that bugs out *
Application.ScreenUpdating = False
Sheets("Data").Select
Application.Goto Reference:="R1C1:R25C7"

Selection.EntireRow.Hidden = False 'bugs out here *
Range("A12:A13").Select
Selection.EntireRow.Hidden = True
Range("A16:A17").Select
Selection.EntireRow.Hidden = True

If I comment out that line it gets as far as the next entirerow etc - it was
working before and I've changed by adding the hidden false line to make sure
that there are not already hidden rows in the range. I've got a separate
reset macro but it makes things slow and can't rely on everyone to use it.

Thank you
 
K

Ken Johnson

Hi everyone,

I'm getting a runtime error that bugs out *
Application.ScreenUpdating = False
    Sheets("Data").Select
    Application.Goto Reference:="R1C1:R25C7"

Selection.EntireRow.Hidden = False 'bugs out here *
    Range("A12:A13").Select
    Selection.EntireRow.Hidden = True
    Range("A16:A17").Select
    Selection.EntireRow.Hidden = True

If I comment out that line it gets as far as the next entirerow etc - it was
working before and I've changed by adding the hidden false line to make sure
that there are not already hidden rows in the range. I've got a separate
reset macro but it makes things slow and can't rely on everyone to use it..

Thank you

Works fine on mine. Is the Data sheet protected?

Ken Johnson
 
D

Don Guillett

Try this from anywhere in the workbook. NO selections

Sub HideRowsOnDataSheet()
With Sheets("Data")
.Rows("1:25").Hidden = False
.Range("A12:A13,a16:a17").EntireRow.Hidden = True
End With
End Sub
 
M

Mifty

Hi Ken,

Thanks for trying it out:)

I've gone back to an earlier version and redone the changes and as you say
it runs fine.

The only thing I can remember doing was to try to change the VBA properties,
I was trying unsucessfully to password the code so that users couldn't alter
- don't know if that could have messed it up?

Thank you
 
M

Mifty

Hi Don,

Thanks for replying.

The original code worked when I went back to an earlier version and re-did
it.
As I put in the message to Ken, I don't know whether the unsuccessful
attempt at putting a password on the code affected it. I can't remember doing
anything else :-(

I've since replaced my code (recorded but I think it's probably very
obvious) with your code.

Thank you
 
M

Mifty

Hi Don,

Yes I'm using your code - I did try to say in last message that I swapped my
recorded code for yours.

The reason why it was working at times but not at others was that whilst I
was working on the workbook protection was off and the code worked. Then
when I thought I was all done protection was turned back on and I also tried
to set a password to the VBA.

Being new to this and not really knowing what I was doing the only change
that I could remember making was trying (and failing) to set password.

I've now found Protect User Interface but failed to realise that the code
had to be rerun at each time wkbk opened.

This part of my project is now working and thank you for your code :) just
the rest of my data val problem that's keeping me up at night :-(
 
M

Mifty

Hi Ken,

Yes, when I put protection on then code stopped working.

I was in such a panic that I forgot I'd done this.

Using Protect Interface only now and working

thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top