Friday, 15 June 2012

Excel VBA Copy Operation (with Hidden Columns in-between) -



Excel VBA Copy Operation (with Hidden Columns in-between) -

i stuck in unusual requirement. next mock of problem.

in cell e1, have value 1.

in cell f1, have value 2.

column b hidden.

now using vba need re-create e1 & f1 cell a1 such a1 contain "1" , c1 contains "2" (because column b hidden)

in short need skip hidden columns while pasting.

i know can 2 re-create operations number of hidden columns , number of cells copied not same always. need re-create operation in 1 shot.

how accomplish using excel vba?

sub tester() copyskippinghidden activesheet.range("a1:c1"), _ activesheet.range("f1") end sub sub copyskippinghidden(rngtocopy range, pastestart range) dim c range each c in rngtocopy.cells while pastestart.entirecolumn.hidden set pastestart = pastestart.offset(0, 1) loop c.copy pastestart set pastestart = pastestart.offset(0, 1) next c end sub

excel vba excel-vba

No comments:

Post a Comment