LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.querydao
external usenet poster
 
Posts: 2
Default Help with code for Macro!

Hello,
I'm trying to create a Macro that does the following:
1. Copies the values of 12 cells from Sheet1 to Sheet2.
2. Perform an import of data from a database that will over-write the values
in the 12 copied cells.
3. Paste the copied values back to their original cells on Sheet1 in 11
columns. The only column that cannot be copied back is the column for the
current month.

I've got #1-#2 completed, but am having problems with #3 because of one
catch. The "monthly" periods run from the 21st of the previous month to the
20th of the current month. So for example, when we get to August 21st, the
current system date should tell the Macro to NOT copy over the September
column, but DO copy over the August column.

In the Macro VB editor I've tried using many functions to do this but the
data comparison's all seem to work incorrectly. For instance, when I use
the [Date] function to return the current system date (8/3/2006) and compare
it like the following, it evaluates True!

If Date "8/29/2006" Then

So it thinks 8/3/2006 is greater than 8/29/2006 because it is looking at the
value, not the dates! I've tried to format it as smalldate and such but it
keeps failing. Any ideas/tips/tricks you could offer would be most
appreciated. Thanks!


 
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
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
Macro code to remove a macro after it executes Charles Excel Programming 4 March 22nd 06 12:11 PM
read macro code by vb code Francesco Geri Excel Programming 2 October 7th 05 10:24 AM
do anybody have a sample code for executing excel macro from vb code?<eom B Deepak Excel Programming 2 September 30th 05 09:59 AM
Macro copying macro code TNSKHelp Excel Programming 1 June 17th 05 04:59 PM


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