can a marco do this.....

tim963

Board Regular
Joined
Aug 20, 2002
Messages
58
For each row in C1:C100 that has anything in it I need to take what’s in column H and paste special valve into column A, so if C1 had something in it, it would take what’s in H1 and paste special valve in A1 then check the other rows, if there is not anything in column C it should go to the next row. I am using excel 97. thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
With [A1:A100]
.FormulaR1C1 = "=IF(RC[2]<>"""",RC[7],"""")"
.Value = .Value
End With
This message was edited by Phil Squod on 2002-09-08 15:50
 
Upvote 0
Hi tim963,

Try this:

<pre>
Sub PasteIt()
Dim rng As Range

Application.ScreenUpdating = False

For Each rng In Range("C1:C100")
If Not rng.Value = "" Then
rng.Offset(0, 5).Copy
rng.Offset(0, -2).PasteSpecial xlPasteValues
End If
Next rng

Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

</pre>
HTH
 
Upvote 0
For the record I tried Phil Squad's code it did not do what I needed, again Richie(UK) code did what I wanted, thanks again
 
Upvote 0
Just for the record, Phil Squod's code produces exactly the same result as Richie(UK)'s - but more efficiently.
 
Upvote 0
Hello Phil or P. Dante:

I am trying to learn VB (in Excel 97) also and I tested Phil's code which works. But can you explain it a bit. Why are there so many "? (e.g. after <>). And the IF statement seems to take RC[7] and put it into the A column, so why the Value statement?

Sorry to bother ye and pardon my ignorance. It is such a short, neat solution.

Thanks,

Gerry
 
Upvote 0
Hi all,

Just for the record (as that seems to be a popular phrase on this post :smile: ):

1. I'm still learning VBA so I make no guarantees as to the 'efficiency' of my code. I just try to make sure it works!

2. I also think Phil's code looks to be more efficient. (As does the formula solution provided by ylijohe).

Tim - try all 3 and go with what suits.

Phil - I'm sure your routine was longer than that to start with. A little refining in the editing perhaps? :wink:
 
Upvote 0

Forum statistics

Threads
1,223,459
Messages
6,172,338
Members
452,454
Latest member
MadamRedRabbit

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top