Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range.Select

I have a very uncomplicated code that is giving me troubles. i hav
been trying to figure this out for much longer than i want to admit.
here is the code.

Private Sub CommandButton2_Click()

msg = "Did you Export the CMS Data to your Clipboard?"
Style = vbYesNo + vbDefaultButton2
Title = "QUESTION"
Ctxt = 1000
Response = MsgBox(msg, Style, Title, Help, Ctxt)

If Response = vbYes Then

Worksheets("RECAP").Select
Columns("aa:iv").ClearContents
Sheet2.Paste Destination:=Sheet2.Range("aA1")
Range("ah7").Select
Sheets("armdore").Select
Range("c9").Select

Do

If IsEmpty(ActiveCell) = False Then

ActiveCell.Offset(0, 1).Select

End If

Loop Until IsEmpty(ActiveCell) = True
'inbound
Sheets("RECAP").Select
Selection.Copy
Sheets("armdore").Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone
skipblanks _
:=False, Transpose:=False
'customer service
Sheets("RECAP").Select
ActiveCell.Offset(2, 0).Select
Selection.Copy
Sheets("armdore").Select
ActiveCell.Offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone
skipblanks _
:=False, Transpose:=False
'TPF sales
Sheets("RECAP").Select
ActiveCell.Offset(4, -1).Select
Selection.Copy
Sheets("armdore").Select
ActiveCell.Offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone
skipblanks _
:=False, Transpose:=False
'TPF corp Sales
Sheets("RECAP").Select
ActiveCell.Offset(2, 0).Select
Selection.Copy
Sheets("armdore").Select
ActiveCell.Offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone
skipblanks _
:=False, Transpose:=False
'P&H sales
Sheets("RECAP").Select
ActiveCell.Offset(4, 1).Select
Selection.Copy
Sheets("armdore").Select
ActiveCell.Offset(3, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone
skipblanks _
:=False, Transpose:=False
'MC sales
Sheets("RECAP").Select
ActiveCell.Offset(-1, 0).Select
Selection.Copy
Sheets("armdore").Select
ActiveCell.Offset(6, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone
skipblanks _
:=False, Transpose:=False
'HS Sales
Sheets("RECAP").Select
ActiveCell.Offset(0, 0).Select
Selection.Copy
Range("ah7").Select
Sheets("armdore").Select
ActiveCell.Offset(6, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, operation:=xlNone
skipblanks _
:=False, Transpose:=False


End If

End Sub

it is giving me the following error: Run-time error '1004': Selec
method of range class failed
when i go to debug it highlights line 14 - range("ah7").select.
i have tried moving this line, and changing it. any suggestions

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Range.Select

"scottnshelly " wrote in
message ...
I have a very uncomplicated code that is giving me troubles. i have
been trying to figure this out for much longer than i want to admit.
here is the code.

Private Sub CommandButton2_Click()


it is giving me the following error: Run-time error '1004': Select
method of range class failed
when i go to debug it highlights line 14 - range("ah7").select.
i have tried moving this line, and changing it. any suggestions?




It sounds like the button that your code is attached to still has
focus. Try changing the TakeFocusOnClick property of the button to
False. This should prevent the error from occurring.

FWIW, it looks like there are several lines of code that could be
removed safely. Most of the stuff that we need to do with code can be
done without changing the selection and referring to
ActiveSheet/ActiveCell. Doing so will improve performance and make
the code easier to maintain.


Hope this helps,

-Mike


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
Select used range [email protected] Excel Worksheet Functions 2 February 19th 09 03:46 AM
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
Select a range [email protected] Excel Discussion (Misc queries) 1 March 22nd 07 10:16 AM
I cannot select a range Kassie Excel Discussion (Misc queries) 3 February 21st 05 06:09 AM


All times are GMT +1. The time now is 06:18 AM.

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"