PC Review


Reply
Thread Tools Rate Thread

Copy Values based on a Match Q

 
 
Sean
Guest
Posts: n/a
 
      8th Mar 2008
I have the code below that Copy-Paste Values-Transposes values in
Column D833 (on sheet Input) to the row that matches the value in D6
(on sheet Input) held in Column A starting in Row 7 (on sheet YTD).

This works great except I have 35 columns in total to copy based on a
match ColA YTD. I can repeat this code 35 times, but is there a way to
incorporate a loop with the code below that will have the same effect?


Sub PostInputValues()
Application.ScreenUpdating = False
Dim sh As Worksheet
Dim rng As Range, rng1 As Range
Dim cell As Range, dt As Date
Set sh = Worksheets("Input")
dt = sh.Range("D6").Value
With Worksheets("YTD")
Set rng = .Range(.Cells(7, 1), .Cells(7, 1).End(xlDown))
End With
For Each cell In rng
If cell.Value2 = CLng(dt) Then
Set rng1 = cell
Exit For
End If
Next
If rng1 Is Nothing Then
MsgBox Format(dt, "dd-mm-yy") & " was not found"
Exit Sub
End If
sh.Range("D833").Copy
rng1.Offset(0, 2).PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=True
Worksheets("YTD").Select
Range("C7").Select

Worksheets("Input").Select
Range("B5").Select
Application.CutCopyMode = False

End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Match Values and Copy Rows K Microsoft Excel Programming 3 23rd Sep 2009 12:22 AM
in a single worksheet,hw to match values based on 2 list Max Microsoft Excel Discussion 2 13th Apr 2009 05:23 AM
copy row based on match and multiple criteria franky Microsoft Excel Programming 1 21st May 2008 06:22 PM
match 2 databases based on a column with same values =?Utf-8?B?amFzb25zZ29hdA==?= Microsoft Excel Misc 0 4th Apr 2006 06:35 PM
How do i compare values from two sheet and copy & paste if values match? =?Utf-8?B?cm96Yg==?= Microsoft Excel Programming 0 5th Mar 2004 12:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:01 PM.