LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default Error in vba module

The first code group works. The second group does not. I get an error:

Run-time error '-2147417848 (80010108)':
Method 'Hidden' of object 'Range' failed

Any ideas on fixing this?

-Using Excel 2000
-Code is placed in Module1
-Original code worked for 2 sheets, when adding 3 sheets, it fails.

Original code:

Sub AddRowNowMacro()
ActiveSheet.Unprotect ("atsi359j")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("atsi359j")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("atsi359j")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("atsi359j")
Sheets("PDSR").Select
End Sub

--------------------------------------------------------------------
Updated code:

Sub AddRowNowMacro()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("Disciplines").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsc As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsc = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsc, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Module error Phanindran U[_2_] Excel Discussion (Misc queries) 1 August 20th 07 09:09 AM
Module error? Steve C Excel Programming 3 April 17th 06 02:56 AM
Module Error justaguyfromky Excel Programming 6 February 15th 06 01:07 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
Compile error in hidden module error Melissa Zebrowski Excel Programming 3 February 20th 04 01:29 PM


All times are GMT +1. The time now is 03:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"