Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What's wrong w/my code?

Sub Copy_Paste()
If Range("D7").Value < "" Then
Sheets("Sheet1").Range("A1").Select
Selection.Copy
Sheets("Sheet2").Select
Range("D7,D9,D15,D17,D19,D21,D23,D25,D27,D29,D31,D 33").Select
Selection.pastespecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "mm/dd/yyyy"
Else
End If
End Sub

I need to run this program from sheet 2 to sheet 10 when as soon a
workbook opens. Ranges should all be the same. Anyone knows a bette
way of doing this??? I keep getting a "1004" error.


Larry
VBA Amateu

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default What's wrong w/my code?

Just a guess:

If Range("D7").Value < "" Then


What sheet?? A 1004 error would be raised if Excel couldn't figure it out
either.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"nrage21 " wrote in message
...
Sub Copy_Paste()
If Range("D7").Value < "" Then
Sheets("Sheet1").Range("A1").Select
Selection.Copy
Sheets("Sheet2").Select
Range("D7,D9,D15,D17,D19,D21,D23,D25,D27,D29,D31,D 33").Select
Selection.pastespecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "mm/dd/yyyy"
Else
End If
End Sub

I need to run this program from sheet 2 to sheet 10 when as soon as
workbook opens. Ranges should all be the same. Anyone knows a better
way of doing this??? I keep getting a "1004" error.


Larry
VBA Amateur


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default What's wrong w/my code?

You should always mention the exact error meessage. 1004 tells us nothing.

It may be that the clipboard is getting cleared out. You don't have to even
used copy/paste and you can skip all the jumping around selecting sheets and
cells. You do not have to select anything. For example:

Sheet2.Range("D7,D9,D15,D17,D19,D21,D23,D25,D27,D2 9,D31,D33").Value _
= Sheet2.Range("A1").Value

would do the first sheet.

If Range("D7").Value < "" Then


This is perplexing. What does less that an empty cell mean?

--
Jim Rech
Excel MVP

"nrage21 " wrote in message
...
| Sub Copy_Paste()
| If Range("D7").Value < "" Then
| Sheets("Sheet1").Range("A1").Select
| Selection.Copy
| Sheets("Sheet2").Select
| Range("D7,D9,D15,D17,D19,D21,D23,D25,D27,D29,D31,D 33").Select
| Selection.pastespecial Paste:=xlPasteValues, Operation:=xlNone,
| SkipBlanks _
| :=False, Transpose:=False
| Application.CutCopyMode = False
| Selection.NumberFormat = "mm/dd/yyyy"
| Else
| End If
| End Sub
|
| I need to run this program from sheet 2 to sheet 10 when as soon as
| workbook opens. Ranges should all be the same. Anyone knows a better
| way of doing this??? I keep getting a "1004" error.
|
|
| Larry
| VBA Amateur
|
|
| ---
| Message posted from http://www.ExcelForum.com/
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What's wrong w/my code?

I forgot what the rest of the 1004 error said... something abou
"Application Function..." cant remember.

I know this VBA Code is shameful... but just learning.

"If Range("D7").Value < "" Then"

I just wanted the program to start running if cell D7 was empty but i
not empty then to end the program and do nothing.

Thanks for your help... now how do you include the other sheets in th
code?

Larry
VBA Amateu

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default What's wrong w/my code?

I just wanted the program to start running if cell D7 was empty

So the test would be:

If Range("D7").Value = "" Then

now how do you include the other sheets in the code?


Worksheets("Sheet2").Range("D7,D9,D15,D17,D19,D21, D23,D25,D27,D29,D31,D33").Value _
= Worksheets("Sheet1").Range("A1").Value

Worksheets("Sheet3").Range("D7,D9,D15,D17,D19,D21, D23,D25,D27,D29,D31,D33").Value _
= Worksheets("Sheet1").Range("A1").Value


--
Jim Rech
Excel MVP
"nrage21 " wrote in message ...
|I forgot what the rest of the 1004 error said... something about
| "Application Function..." cant remember.
|
| I know this VBA Code is shameful... but just learning.
|
| "If Range("D7").Value < "" Then"
|
| I just wanted the program to start running if cell D7 was empty but if
| not empty then to end the program and do nothing.
|
| Thanks for your help... now how do you include the other sheets in the
| code?
|
| Larry
| VBA Amateur
|
|
| ---
| Message posted from http://www.ExcelForum.com/
|


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default What's wrong w/my code?

Thanks so much Jim! :)

Larry
VBA Amateu

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

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
What is wrong with this code? Ayo Excel Discussion (Misc queries) 14 June 10th 08 03:09 AM
What is wrong with this code? jlclyde Excel Discussion (Misc queries) 5 January 9th 08 05:12 PM
What is wrong with the code? Eric Excel Discussion (Misc queries) 2 September 13th 07 10:36 AM
Can someone tell me what is wrong with this code? Ant Excel Discussion (Misc queries) 8 November 14th 05 02:53 PM
What's wrong with my code ? christophe meresse Excel Worksheet Functions 3 August 2nd 05 05:09 PM


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