Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to look up values in 2 different columns

Hi,

I need a macro which compares the values in colA and colC of sheet 1
to column D and column E of sheet 2, if both the value match, then it
copies the contents from sheet2 col F,G and H into sheet1 colC,D and
F.

Please advise.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro to look up values in 2 different columns

Sub CompareThis()

For iRow = 1 to 1000

If Sheets("Sheet1").cells(iRow, 1).Value = Sheets("Sheet2").cells
(iRow, 4).Value And _
Sheets("Sheet1").cells(iRow, 3).Value = Sheets("Sheet2").cells(iRow,
5).Value Then

Sheets("Sheet1").cells(iRow, 3).Value = Sheets("Sheet2").cells(iRow,
6).Value
Sheets("Sheet1").cells(iRow, 4).Value = Sheets("Sheet2").cells(iRow,
7).Value
Sheets("Sheet1").cells(iRow, 5).Value = Sheets("Sheet2").cells(iRow,
8).Value

End IF

Next iRow

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to look up values in 2 different columns

Thanks Hiran,

I'll try this out.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Macro to look up values in 2 different columns

hello Hiran,

The code above gives an error saying: Subscript out of
Range.Can you please advise.

Thanks
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
macro to hide columns with zero values? K Dawson Excel Discussion (Misc queries) 1 March 23rd 10 06:31 PM
Macro to hide rows with zero values in columns K Dawson Excel Discussion (Misc queries) 2 March 23rd 10 03:00 PM
Macro to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
Macro to copy columns values Mike_can Excel Programming 1 May 29th 06 04:24 AM
How do I denote values stored in columns in my macro? Greg Excel Programming 3 June 8th 05 07:43 PM


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