Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Application-defined or object-defined error

Basically I want to fill cells in workbook PeriodXX with
cells from workbook 202forecast.
First I get a number from the user, then I use that to
pick which sheet the data comes from:

Sub UpdatePeriodXX()
PeriodNum = Application.InputBox("Please Enter The Period
Number")
Worksheets("WEEKONE").Range("PERIOD").Value = PeriodNum

Select Case PeriodNum
Case 1
UpdateWeek1
Case 2
UpdateWeek2
Case Else
Exit Sub
End Select
End Sub 'it gets thru this ok

Sub UpdateWeek1()
Workbooks("PeriodXXInProcess.xls").Worksheets
("WEEKONE").Range("Salary").Value = Workbooks
("202forecast.xls").Worksheets(PeriodNum).Range
("Salary").Value 'this is the line that errors out
End Sub

"Salary" is a range of cells.
I named a range in both workbooks as Salary. I want to
fill one range with the values from the other one. Is
that not possible? Or is the syntax just wrong?

Thank you -
Sharon
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application-defined or object-defined error

I always use the names collection in a situation like this

Sub UpdateWeek1()
Workbooks("PeriodXXInProcess.xls"). _
Worksheets("WEEKONE").Names("Salary"). _
RefersToRange.Value = _
Workbooks("202forecast.xls"). _
Worksheets(periodNum).Names("Salary"). _
RefersToRange.Value
End Sub

--
Regards,
Tom Ogilvy



Sharon wrote in message
...
Basically I want to fill cells in workbook PeriodXX with
cells from workbook 202forecast.
First I get a number from the user, then I use that to
pick which sheet the data comes from:

Sub UpdatePeriodXX()
PeriodNum = Application.InputBox("Please Enter The Period
Number")
Worksheets("WEEKONE").Range("PERIOD").Value = PeriodNum

Select Case PeriodNum
Case 1
UpdateWeek1
Case 2
UpdateWeek2
Case Else
Exit Sub
End Select
End Sub 'it gets thru this ok

Sub UpdateWeek1()
Workbooks("PeriodXXInProcess.xls").Worksheets
("WEEKONE").Range("Salary").Value = Workbooks
("202forecast.xls").Worksheets(PeriodNum).Range
("Salary").Value 'this is the line that errors out
End Sub

"Salary" is a range of cells.
I named a range in both workbooks as Salary. I want to
fill one range with the values from the other one. Is
that not possible? Or is the syntax just wrong?

Thank you -
Sharon



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Application-defined or object-defined error

I'm just learning about collections, so I'll have to read
up on that. I tried the code and I get the same error.
But thank you -
Maybe I'll just need to do a copy and paste.
Sharon

-----Original Message-----
I always use the names collection in a situation like this

Sub UpdateWeek1()
Workbooks("PeriodXXInProcess.xls"). _
Worksheets("WEEKONE").Names("Salary"). _
RefersToRange.Value = _
Workbooks("202forecast.xls"). _
Worksheets(periodNum).Names("Salary"). _
RefersToRange.Value
End Sub

--
Regards,
Tom Ogilvy



Sharon wrote in message
...
Basically I want to fill cells in workbook PeriodXX with
cells from workbook 202forecast.
First I get a number from the user, then I use that to
pick which sheet the data comes from:

Sub UpdatePeriodXX()
PeriodNum = Application.InputBox("Please Enter The

Period
Number")
Worksheets("WEEKONE").Range("PERIOD").Value = PeriodNum

Select Case PeriodNum
Case 1
UpdateWeek1
Case 2
UpdateWeek2
Case Else
Exit Sub
End Select
End Sub 'it gets thru this ok

Sub UpdateWeek1()
Workbooks("PeriodXXInProcess.xls").Worksheets
("WEEKONE").Range("Salary").Value = Workbooks
("202forecast.xls").Worksheets(PeriodNum).Range
("Salary").Value 'this is the line that errors out
End Sub

"Salary" is a range of cells.
I named a range in both workbooks as Salary. I want to
fill one range with the values from the other one. Is
that not possible? Or is the syntax just wrong?

Thank you -
Sharon



.

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
Run-time error '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
Application-defined or object-defined error Please Help [email protected] Excel Discussion (Misc queries) 1 April 3rd 06 01:00 PM
Application-defined or object-defined error Meihua Liang Excel Programming 0 September 8th 03 07:25 PM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM
VBA - Application-defined or object-defined error Chip Pearson Excel Programming 0 August 24th 03 08:43 PM


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