Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Finding the last cell in a protected sheet

The command:

SpecialCells(xlLastCell).Select

fails if my worksheet is protected. Is there any way round this without
resorting to unprotecting the sheet (I don't want to have to hard code the
password in my macro)?

Thanks

TM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Finding the last cell in a protected sheet

Oh it's OK, just found the answer in the archive :-) Duh!

myLastCol = _
..Cells.Find("*", After:=.Cells(1), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column

Thanks anyway

TM

"TishyMouse" wrote:

The command:

SpecialCells(xlLastCell).Select

fails if my worksheet is protected. Is there any way round this without
resorting to unprotecting the sheet (I don't want to have to hard code the
password in my macro)?

Thanks

TM

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Finding the last cell in a protected sheet

mylastCol = cells.specialcells(xlLastcell).Column

--
Regards,
Tom Ogilvy




"TishyMouse" wrote:

Oh it's OK, just found the answer in the archive :-) Duh!

myLastCol = _
.Cells.Find("*", After:=.Cells(1), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column

Thanks anyway

TM

"TishyMouse" wrote:

The command:

SpecialCells(xlLastCell).Select

fails if my worksheet is protected. Is there any way round this without
resorting to unprotecting the sheet (I don't want to have to hard code the
password in my macro)?

Thanks

TM

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Finding the last cell in a protected sheet

THanks, Tom, but that is the command that I was trying originally doesn't
seem to work on a protected sheet.

The 'find' method works fine, it's just a bit longer.

"Tom Ogilvy" wrote:

mylastCol = cells.specialcells(xlLastcell).Column

--
Regards,
Tom Ogilvy




"TishyMouse" wrote:

Oh it's OK, just found the answer in the archive :-) Duh!

myLastCol = _
.Cells.Find("*", After:=.Cells(1), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column

Thanks anyway

TM

"TishyMouse" wrote:

The command:

SpecialCells(xlLastCell).Select

fails if my worksheet is protected. Is there any way round this without
resorting to unprotecting the sheet (I don't want to have to hard code the
password in my macro)?

Thanks

TM

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Finding the last cell in a protected sheet

Sub ABC()
ActiveSheet.Protect UserInterfaceOnly:=True
Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell)
lastcol = rng.Column
MsgBox lastcol
End Sub

worked fine for me on a protected sheet. If it is password protected, in
xl2002 and later you would have to supply the password.

--
Regards,
Tom Ogilvy


"TishyMouse" wrote:

THanks, Tom, but that is the command that I was trying originally doesn't
seem to work on a protected sheet.

The 'find' method works fine, it's just a bit longer.

"Tom Ogilvy" wrote:

mylastCol = cells.specialcells(xlLastcell).Column

--
Regards,
Tom Ogilvy




"TishyMouse" wrote:

Oh it's OK, just found the answer in the archive :-) Duh!

myLastCol = _
.Cells.Find("*", After:=.Cells(1), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column

Thanks anyway

TM

"TishyMouse" wrote:

The command:

SpecialCells(xlLastCell).Select

fails if my worksheet is protected. Is there any way round this without
resorting to unprotecting the sheet (I don't want to have to hard code the
password in my macro)?

Thanks

TM



Reply
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
Change cell color in protected sheet ansa Excel Worksheet Functions 2 May 2nd 13 12:34 PM
how to paste a fomulae cell in a protected sheet angeline Excel Programming 0 October 17th 06 05:48 AM
finding the password to unlock a protected cell/chart Pizza Charts and Charting in Excel 3 June 13th 06 01:17 PM
Can I allow cell merging in a protected sheet PatM Excel Worksheet Functions 1 December 13th 05 03:06 PM
Un-proteced Cell in a Protected Sheet SU Excel Discussion (Misc queries) 1 April 20th 05 06:41 PM


All times are GMT +1. The time now is 10:57 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"