LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default using sheet code name

Hi,
I've been modifying my existing, working code to use sheet code names,
rather than sheet label names, and I am getting the "method 'select'
of object '_worksheet' failed".
In using the codenames, are there perhaps other areas of my code that
need adjustment?
Thanks,
Louis

-----
Sub timesheetGenerate()
Dim fillamt As Long
Dim origDate As Date

Dim LOldWb As Workbook
Dim LNewWb As Workbook
Dim x As Name

'Open existing timesheet
Set LOldWb = Workbooks.Open(Filename:=UserForm1.TextBox1.Value)

'Add new workbook
Set LNewWb = Workbooks.Add

'Get data from Sheet 3 (dates) of existing timesheet
LOldWb.Activate
Sheet3.Visible = xlSheetVisible
Sheet3.Select


LNewWb.Activate
Sheet3.Select
Cells(1, 1).Select
ActiveCell.Value = UserForm1.TextBox4.Value

'\\\\Populate Column A with date range
fillamt = UserForm1.TextBox6.Value
Selection.AutoFill Destination:=Range("A1:A" & fillamt),
Type:=xlFillSeries



'Copy sheet one of existing timesheet
LOldWb.Activate
Sheet1.Select
Cells.Select

'///replace formula with string
Selection.Replace What:="=", Replacement:="$$$$$=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False
'///copy all
Selection.Copy


'Paste sheet one to new timesheet
LNewWb.Activate
Sheet1.Select
'///paste all (values)
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
'///replace string with formula
Cells.Select
Selection.Replace What:="$$$$$=", Replacement:="=",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False



'Copy sheet two of existing timesheet
LOldWb.Activate
Sheet2.Select
Cells.Select
'///replace formula with string
Selection.Replace What:="=", Replacement:="$$$$$=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False
'///copy all
Selection.Copy



'Paste sheet two to new timesheet
LNewWb.Activate
Sheet2.Select
'///paste all (values)
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
'///replace string with formula
Cells.Select
Selection.Replace What:="$$$$$=", Replacement:="=",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False


Sheet1.Select


' Loop through all of the defined names in the active
' workbook.
For Each x In LOldWb.Names
' Add each defined name from the active workbook to
' the target workbook ("Book2.xls" or "Book2.xlsm").
' "x.value" refers to the cell references the
' defined name points to.
LNewWb.Names.Add Name:=x.Name, _
RefersTo:=x.Value
Next x

ActiveWorkbook.SaveAs Filename:=UserForm1.TextBox2.Value


'\\\\
ActiveWorkbook.Close
'\\\\

'\\\\
LOldWb.Activate

ActiveWorkbook.Close

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
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Programmatically determining CODE NAME for sheet based upon Sheet Barb Reinhardt Excel Programming 14 August 15th 06 06:49 PM
Sheet Code Module: copying code to [email protected][_2_] Excel Programming 2 December 14th 04 01:57 AM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM
unprotect sheet in code and make sheet visible peach255 Excel Programming 1 August 1st 03 03:28 AM


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

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

About Us

"It's about Microsoft Excel"