Hi all

need a little help please. i'm using VB (but very very rusty) and i need to write a simple macro to cut and paste in excel.

the macro so far is:

Sub populate()
'
' populate Macro
' Macro recorded 09/02/2010 by
'

'

    'select correct cell
    Range("D6").Select
    'enter lookup
    ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'10'!C6:C7,2,0)"
    
    'copy selection
    Range("D6").Select
    Selection.Copy
    'paste first half
    Range("D6:D10").Select
    ActiveSheet.Paste
    'paste second half
    Range("D13:D17").Select
    ActiveSheet.Paste
    
    

End Sub

but, what i want to do is paste the range along the sheet from column D to column CX (incrementing in 2's as i go along)..

so i would paste in D, then F, then H etc....

how do i do it? can i use a variable for the column and increment this in a loop or is there some other way??

thanks in advance

Recommended Answers

All 2 Replies

Try recording a macro and then looking at the code...

Good Luck

thats what i did....

but it doesnt show how to increment the cell values..

its sorted now, i can use a variable by using the cells keyword instead of the actual cell reference.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.