PC Review


Reply
Thread Tools Rate Thread

Copy and Past Macro

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      21st Sep 2007

I have a formula that looks for matching criteria (in cell I1 vs.
Column A) and copies the values to the right of it and pastes them in
E (starting with E1).

What I need to do is the same except the last part (starting with E1).
I need to copy, but a lateral move (like shown below).

If the matching value is found on row 2, then copy and paste the
target cells value directly over on the same row.


A B C D E F G H I
9/3 ABC 9/4
9/4 DEF DEF
9/3 GHI
9/4 JKL JKL

The formula that I am working with is as follows:

Sub macro3()
Dim ws As Worksheet
Dim iA As Integer
Dim iB As Integer
Dim c As Range
Dim rng As Range


Set ws = Worksheets("Sheet1")
Set rng = ws.Range("A1:A65536")
For Each c In rng
If c = Range("I1") Then
iA = iA + 1
ws.Cells(iA, 5) = c.Offset(0, 1)
End If
Next c
End Sub

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      21st Sep 2007
Sub macro3()
Dim c As Range
Dim rng As Range
Dim ws As Worksheet

Set ws = Worksheets("Sheet1")
Set rng = ws.Range("A1:A" & ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)
For Each c In rng
If c.Value = Range("I1").Value Then
c.Offset(0, 4).Value = c.Offset(0, 1).Value
End If
Next c
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> I have a formula that looks for matching criteria (in cell I1 vs.
> Column A) and copies the values to the right of it and pastes them in
> E (starting with E1).
>
> What I need to do is the same except the last part (starting with E1).
> I need to copy, but a lateral move (like shown below).
>
> If the matching value is found on row 2, then copy and paste the
> target cells value directly over on the same row.
>
>
> A B C D E F G H I
> 9/3 ABC 9/4
> 9/4 DEF DEF
> 9/3 GHI
> 9/4 JKL JKL
>
> The formula that I am working with is as follows:
>
> Sub macro3()
> Dim ws As Worksheet
> Dim iA As Integer
> Dim iB As Integer
> Dim c As Range
> Dim rng As Range
>
>
> Set ws = Worksheets("Sheet1")
> Set rng = ws.Range("A1:A65536")
> For Each c In rng
> If c = Range("I1") Then
> iA = iA + 1
> ws.Cells(iA, 5) = c.Offset(0, 1)
> End If
> Next c
> End Sub
>



 
Reply With Quote
 
J.W. Aldridge
Guest
Posts: n/a
 
      21st Sep 2007

When I get my first million....... I'm buying you a Krystal Burger
(with Cheese!)

THANX!!!!!!!!!

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      21st Sep 2007
Big spender

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"J.W. Aldridge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> When I get my first million....... I'm buying you a Krystal Burger
> (with Cheese!)
>
> THANX!!!!!!!!!
>


 
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
Help needed... please (Copy Past Macro) =?Utf-8?B?bXlkb2dwZWFudXQ=?= Microsoft Excel Programming 0 19th Oct 2007 03:17 PM
Copy & Past Macro Question =?Utf-8?B?bXlkb2dwZWFudXQ=?= Microsoft Excel Programming 2 19th Oct 2007 02:58 PM
Macro to copy and past a new row when the a row is filled in. =?Utf-8?B?bG9va0xpa2VXb3Jrcw==?= Microsoft Excel Programming 1 29th Jul 2007 10:36 PM
Copy Past with macro Murat D. Hekimolu Microsoft Excel Programming 1 24th May 2005 02:00 PM
Macro to copy and past selected rows only... =?Utf-8?B?SnVsZXM=?= Microsoft Excel Programming 1 14th Apr 2004 02:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:09 AM.