# Solved Excel Macro to copy based on if function

August 15, 2011 at 08:32:24
Specs: Windows XP
 Hi,If I have a sheet (Sheet1) with 3 columns (A, B and C) with data from row 2 to 100, where: columns A and B have text and column C has TRUE/FALSE.I would like to have a macro to copy the text of column A (if True) or B (if False) to column D.Note that I cannot reference cells as same text is strikethrough. Basically an if function would solve if the text was not strikethrough!Would really appreciate an help on this.Many thanks

See More: Excel Macro to copy based on if function

#1
August 15, 2011 at 13:20:37
 I do not know what this means:"Note that I cannot reference cells as same text is strikethrough"Please post an example of what you are trying to do. Click on the following line and read the instructions found at that link before posting any data.Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

#2
August 15, 2011 at 14:01:32
 Apologize, I mean "some" instead of "same"! For example:```A B C E111 E111 TRUE E222 E222 FALSE ```What I want is column D to copy text of column A (if column C is True) or B (if column C is False) but with the same font format. If cell B2 was italic, bold or strikethrough, cell D2 also has to be!Thanks a lot.

Report •

#3
August 15, 2011 at 18:11:55
 ```Option Explicit Sub CopyFont() Dim lastRw, nxtRw As Integer 'Determine last row with data lastRw = Range("A" & Rows.Count).End(xlUp).Row 'Loop through rows For nxtRw = 1 To lastRw 'Copy Column A or B based on Column C If Cells(nxtRw, 3) = True Then Cells(nxtRw, 1).Copy Cells(nxtRw, 4).PasteSpecial Else Cells(nxtRw, 2).Copy Cells(nxtRw, 4).PasteSpecial End If Next End Sub ```Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.