Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Rob Gould
 
Posts: n/a
Default Help with Macro please!

Hi all,

I am trying to get a macro to work in Excel. Basically, this is what I
want it to do:

A user will enter a date into a cell, say A1 on Sheet 1. They then
enter some sales figures in cells below this. These figures are picked
up on Sheet 2 in Row 1 so that they are all in a row. Below this row I
have all the days of the year. Once the user has finished entering the
figures, the macro needs to copy the row of data on Sheet 2 and paste
Values Only to the row corresponding to the date entered. This way, I
am building up a year of data. I don't want users entering data
directly onto Sheet 2.

Doing this manually, I copy the date entered on Sheet 1, go to Sheet 2,
CTRL+F to Find, paste the date into the find what box, find the cell
with the date, close the find box, move 1 cell to the right and enter
"qq" (could be anything really). Then I copy the row of data in
row A of Sheet 2, Find "qq" and paste values only.

When I incorporate this into a macro, however, it stops during the find
the date section of the process.

Question 1: Is there a far better way of doing this?
Question 2: If not, how do I solve the problem?

This looks pretty confusing, I'm sure, but if you have the time to
try to follow it, I would appreciate the help!

Regards,

Rob

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Rob,

Give this a try. It assumes that the dates are in A2, A3, etc,. so
calculates the row number based upon this.

Sub Test()
Dim cLastRow As Long
Dim cLastCol As Long
Dim thisDate As Date
Dim i As Long

cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To cLastRow
Worksheets("Sheet2").Cells(1, i - 1).Value = _
Cells(i, "A").Value
Next i
thisDate = Range("A1").Value

With Worksheets("Sheet2")
.Range("A1").Resize(1, i - 1).Copy _
Destination:=.Cells(thisDate - DateSerial(Year(thisDate), 1, 0)
+ 1, "B")
End With

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob Gould" wrote in message
oups.com...
Hi all,

I am trying to get a macro to work in Excel. Basically, this is what I
want it to do:

A user will enter a date into a cell, say A1 on Sheet 1. They then
enter some sales figures in cells below this. These figures are picked
up on Sheet 2 in Row 1 so that they are all in a row. Below this row I
have all the days of the year. Once the user has finished entering the
figures, the macro needs to copy the row of data on Sheet 2 and paste
Values Only to the row corresponding to the date entered. This way, I
am building up a year of data. I don't want users entering data
directly onto Sheet 2.

Doing this manually, I copy the date entered on Sheet 1, go to Sheet 2,
CTRL+F to Find, paste the date into the find what box, find the cell
with the date, close the find box, move 1 cell to the right and enter
"qq" (could be anything really). Then I copy the row of data in
row A of Sheet 2, Find "qq" and paste values only.

When I incorporate this into a macro, however, it stops during the find
the date section of the process.

Question 1: Is there a far better way of doing this?
Question 2: If not, how do I solve the problem?

This looks pretty confusing, I'm sure, but if you have the time to
try to follow it, I would appreciate the help!

Regards,

Rob



  #3   Report Post  
Rob Gould
 
Posts: n/a
Default

Hi Bob,

Thanks for that, but I can't seem to get it to work. This is probably
because the example I gave was to illustrate the problem. The actual
arrangement of my data is as follows:

Data to copy is in cells G1:BH1 on the "Data" worksheet
Date to use is in A4 on "Dates" worksheet
Date range to look up date is E7:E377 on the "Data" worksheet
Data to then be pasted in col G in row corresponding to date.

Hope this helps you to help me!

Rob

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
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
automatic macro update boconnell Excel Worksheet Functions 4 February 9th 05 07:10 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


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