Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50163

If cell contains a number copy/paste macro

$
0
0
I have the following which checks to see if a number is in column A and if it is copy and paste it. I want to alter it so that if it finds the number in say, A5 it pastes the value in B5. Or if it finds it in A20 then it pastes it in B20. Also, I want it to not only copy and paste if it finds a number on its own within a cell, but also copy and paste for example A12 if A12 is "Text 12 Test" then B12 would be Text 12 Test"
Code:

Sub Test3()
Dim lr As Long
Dim rcell As Range

lr = Cells(Rows.Count, 1).End(xlUp).Row

For Each rcell In Range("A1:A" & lr)

    If IsNumeric(rcell) = True Then
   
        rcell.Copy Sheets("Sheet1").Range("B" & Rows.Count).End(3)(2)
       
    End If
   
Next rcell

End Sub


Viewing all articles
Browse latest Browse all 50163

Trending Articles