Matching user entry to database value and pasting to correct cells

D

Don

I have a workbook with 2 worksheets. Basically it is a daily sales
log. On worksheet 1 the user will input multiple daily sales figures
and the date. Worksheet 2 is the historical sales figures. The
theoretical usage will be for the end user to go to worksheet 1,
enter
the date and daily sales figures and click the save data button. I
am
seeking a formula that will look at the date entry and paste the
values from worksheet 1 into the proper line on worksheet 2 based on
the date entry from worksheet 1.

Example: Column A of worksheet 2 is simply a list of dates. January
13, 2010 is in cell A378. The user makes the entries on worksheet 1
including 01/13/2010 in cell D1 of worksheet 2. Sales figures are
enterred into multiple lines of worksheet 2 starting with cell D5.
When the user clicks the save data button, I need the formula or
script that will look at W1, Cell D1, match it to the corresponding
entry in column A on worksheet 2, in this case A378 and record the
sales figures from worksheet 1 in the correct columns of line 378 on
worksheet 2.


As always, your assistance is greatly appreciated.
Don
 
J

joel

Try something like this. I think there were a few inconsistencies i
your posting so I'm not sure if I got it right.

with Sheets("Sheet1")
W1 = .Range("D1")
Amount = .range("B1")
end with


with Sheets("Sheet2")
'convert the date to a string to be used in the search in column A
DateStr = format(W1,"mm/dd/yyyy")
set c
.columns("A").find(what:=DateStr,lookin:=xlvalues,lookat:=xlwhole)
if c is nothing then
msgbox("Cannot find Date : " & DateStr)
else
LastCol = .cells(c.row,columns.count).end(xltoleft).column
if LastCol < 5 then
NewCol= 5
else
NewCol = Lastcol + 1
end if
.cells(c.row,NewCol) = Amount
end if
end wit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top