LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Excel ComboBox / Copy Error

Your sheet reference is in the wrong place. When you are refering to a sheet
from a userform or another sheet you must put the sheet reference with the
lowest level, in this case the Cells property not the Range property.

Your modified code is below:

If cmbSELECT.Value = "HC" Then
Range(Sheets("HCDATA").Cells(2, 1), Sheets("HCDATA").Cells(84, 1)).Copy _
Destination:=Worksheets("REGRESSION").Range(Cells( 9, 2), Cells(91, 2))
ElseIf cmbSELECT.Value = "LC" Then
Range(Sheets("LCDATA").Cells(2, 1), Sheets("LCDATA").Cells(84, 1)).Copy _
Destination:=Worksheets("REGRESSION").Range(Cells( 9, 2), Cells(91, 2))
End If


"Steve" wrote:

I receive an error code of '1004' when I use the following code:

Public Sub cmbSelect_Click()
If cmbSelect.Value = "HC" Then
Worksheets("HCDATA").Range(Cells(2, 1), Cells(84, 1)).Copy
Destination:=Worksheets("REGRESSION").Range(Cells( 9, 2), Cells(91, 2))
ElseIf cmbSelect.Value = "LC" Then
Worksheets("LCDATA").Range(Cells(2, 1), Cells(84, 1)).Copy
Destination:=Worksheets("REGRESSION").Range(Cells( 9, 2), Cells(91, 2))
End If
End Sub

I believe its caused by the fact that I cannot get focus on the sheet I want
to copy from when using the combobox. Is there any way around this?

 
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
Copy with ComboBox Jari Excel Programming 0 December 4th 05 09:46 AM
Error 13 with combobox Linebaker[_2_] Excel Programming 2 August 11th 05 01:34 AM
Combobox creates error Stephen Excel Worksheet Functions 0 January 23rd 05 10:55 AM
error (ComboBox-?) Alex Excel Programming 2 June 18th 04 02:52 AM
Excel - Copy range of cells based on Combobox Selection Excel-erate2004 Excel Programming 2 April 3rd 04 05:35 PM


All times are GMT +1. The time now is 11:50 AM.

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"