LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
ALP ALP is offline
external usenet poster
 
Posts: 2
Default Excel - Marco error .......HELP

Good afternoon all,

I am having a problem converting a marco to a command button. When I run
this marco .... TOOLS, MARCO, MACROS..., (name).. RUN , the marco runs
correct. When I copy clip the marco to the View Code in the command button,
it does not work. Below is a attached file that might be able to explain it
better. Please help, or what can I do to fix.

Thanks,
ALP

This is what I have in the accutal MARCO. (this works, when I run the marco)

Dim myRange As Range
Set myRange = Worksheets("Work").Range("L1")

If myRange = 1 Then

Range("R4:R36").Select
Selection.Copy
Sheets("QDATA").Select
Range("C4").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.SmallScroll Down:=1
Sheets("WORK").Select
ActiveWorkbook.SAVE
Range("A2").End(xlUp).Select

ElseIf myRange = 2 Then

Range("R4:R36").Select
Selection.Copy
Sheets("QDATA").Select
Range("D4").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.SmallScroll Down:=1
Sheets("WORK").Select
ActiveWorkbook.SAVE
Range("A2").End(xlUp).Select

This is what happens when I try to set this marco to be on my
CommandButton1. (doesnt work)

Private Sub CommandButton1_Click()

Dim myRange As Range
Set myRange = Worksheets("Work").Range("L1")

If myRange = 1 Then

Range("R4:R36").Select
Selection.Copy
Sheets("QDATA").Select
Range("C4").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.SmallScroll Down:=1
Sheets("WORK").Select
ActiveWorkbook.SAVE
Range("A2").End(xlUp).Select


ElseIf myRange = 2 Then

Range("R4:R36").Select
Selection.Copy
Sheets("QDATA").Select
Range("D4").Select ................ this is what is highlighted as error
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.SmallScroll Down:=1
Sheets("WORK").Select
ActiveWorkbook.SAVE
Range("A2").End(xlUp).Select


My error message is:

Run-Time error '1004':
Select Method of Range class failed.

 
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
Marco Exits without error jlclyde Excel Discussion (Misc queries) 1 June 8th 11 12:02 AM
Excel Marco for IP Address [email protected] Excel Worksheet Functions 1 August 17th 06 07:05 PM
how to use marco in excel rnparikh New Users to Excel 9 August 2nd 05 12:08 AM
excel Marco question ... need help please ALP Excel Discussion (Misc queries) 3 March 1st 05 03:11 PM
Excel marco upgrade DaveBerk Excel Programming 0 December 15th 04 01:37 PM


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