Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have 2 excel worksheets assuming "sheet1" and "sheet2". example: Sheet1: user date1 date2 date3 date4 date5...dateN AA BB CC Sheet2: user data date1 date2 date3 date4 date5 dateN AA total 100 102............................................. AA mean 30 32.............................................. AA Average 31 35................................................ CC total............................................. ........................... CC mean.............................................. ....................... CC average........................................... ........................ I want to match the user and date between the 2 sheets and copy the value "mean" from sheet2 to sheet1 if match found. The code below does not return any error but no data was copied over eventhough I can see the match. After some tries, I found that it happened because of the 2nd match (matching the date) does not return any match although the dates are exactly the same in both sheets. My dates are in the following format: MM/DD/YY. When I put an apostrophe in front of the dates to convert them to text then everything worked fine. However, I don't want to convert my dates to text but prefer to keep them as dates. Could anyone help me to resolve the issue with matching date. Thanks a lot, Minnie With Sheets("sheet1") For i = 2 To lastRow With .Range("B" & i) X = Application.Match(.Value, Sheets("sheet2").Range("A2:A10000"), 0) If IsNumeric(X) Then For j = 2 To lastColumn With Cells(1, j) temp = Application.Match(.Value, Sheets("sheet2").Range("C1:Z1"), 0) If IsNumeric(temp) Then 'MsgBox (temp) Sheets("sheet2").Cells(X + 1, 2 + temp).Copy Destination:=Sheets("sheet1").Cells(i, 1 + j) End If End With Next j End If End With Next i End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
match one column with dates to several colums with dates, copy pas | Excel Programming | |||
Counting dates in multiple work sheets and work books | Excel Discussion (Misc queries) | |||
Match Command | Excel Programming | |||
I want to combine a "match" command with a copy and paste command. | Excel Programming | |||
Userform: Combobox, dates, match required- can't get date format to work | Excel Programming |