LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Help on Matching and Copying Values In Two Different Sheets

The code below is an attempt to match column A sheet1 and column A
sheet2. Where a match exist, then copy the cell content in column F
sheet1 to the corresponding cell in column F sheet2. I guess i have
problem with the syntax on this line:
sh2.Cells.Offset(0, 6).Value = sh1.Cells.Offset(0, 6).Value

The entire code is shown below:

Dim sh1 As Worksheet, sh2 As Worksheet
Dim rng1 As Range, rng2 As Range
Dim cell As Range, res As Variant
Set sh1 = Worksheets("SHEET1")
Set sh2 = Worksheets("SHEET2")
Set rng1 = sh1.Range(sh1.Cells(2, 1), sh1.Cells(2, 1).End(xlDown))
Set rng2 = sh2.Range(sh2.Cells(2, 1), sh2.Cells(2, 1).End(xlDown))
For Each cell In rng2
res = Application.Match(cell.Value, rng1, 0)
If Not IsError(res) Then

sh2.Cells.Offset(0, 6).Value = sh1.Cells.Offset(0, 6).Value

End If
Next


Thanks in advance

 
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
Matching Columns in work sheets and copying both rows to new Shelley68 Excel Discussion (Misc queries) 1 March 19th 10 07:09 PM
Copying as absolute values across multiple sheets TeeJay Excel Discussion (Misc queries) 3 October 18th 07 09:45 AM
Copying values between sheets bbuzz Excel Programming 3 November 1st 05 10:53 PM
Copying Values to matching labels Craig[_24_] Excel Programming 2 October 25th 05 12:20 AM
Fill values into a listbox matching selected values from a combobox Jon[_19_] Excel Programming 4 January 25th 05 04:25 PM


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