Tidy recorder code to remove activate and select

Hoggle

New Member
Joined
Jan 21, 2008
Messages
43
I'm using the code below - recorded to move populated cells from one worksheet to another. I have 31 columns of comments to copy from one sheet to another and I can see this macro is very clunky but I can't seem to get the syntax right when I try to remove bits that I think are not necessary. My brain hurts, can someone please give me a pointer in the right direction?
Code:
Columns("B:B").Select
    Selection.SpecialCells(xlCellTypeConstants, 23).Select
    Selection.Copy
    Sheets("Comments").Select
    Range("A3").Select
    ActiveSheet.Paste
    Sheets("HT Review").Select
    Columns("D:D").Select
    Selection.SpecialCells(xlCellTypeConstants, 23).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Comments").Select
    Range("B3").Select
    ActiveSheet.Paste
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

somnath_it2006

Well-known Member
Joined
Apr 11, 2009
Messages
574
Try This:

Code:
    Application.ScreenUpdating = False

    Sheets("HT Review").Columns("B:B").SpecialCells(xlCellTypeConstants, 23).Copy
    Sheets("Comments").Range("A3").PasteSpecial (xlPasteAll)
    Application.CutCopyMode = False
    
    Sheets("HT Review").Columns("B:B").SpecialCells(xlCellTypeConstants, 23).Copy
    Sheets("Comments").Range("B3").PasteSpecial (xlPasteAll)
    Application.CutCopyMode = False
    
    Application.ScreenUpdating = True
 

somnath_it2006

Well-known Member
Joined
Apr 11, 2009
Messages
574

ADVERTISEMENT

Sorry.... Please take this updated code:

Code:
    Application.ScreenUpdating = False

    Sheets("HT Review").Columns("B:B").SpecialCells(xlCellTypeConstants, 23).Copy
    Sheets("Comments").Range("A3").PasteSpecial (xlPasteAll)
    Application.CutCopyMode = False
    
    Sheets("HT Review").Columns("D:D").SpecialCells(xlCellTypeConstants, 23).Copy
    Sheets("Comments").Range("B3").PasteSpecial (xlPasteAll)
    Application.CutCopyMode = False
    
    Application.ScreenUpdating = True
 

Hoggle

New Member
Joined
Jan 21, 2008
Messages
43
Thanks for your help, am going to test now. Had noticed the column names needed changed.....

Will let you know if I have any problems
 

Hoggle

New Member
Joined
Jan 21, 2008
Messages
43
Your code works great except I now want to only copy from row 2 to the last used row in the "HT Review" sheet can I amend the code to read

Code:
Sheets("HT Review").Columns("B2:B" & lastcell).SpecialCells(xlCellTypeConstants, 23).Copy
    Sheets("Comments").Range("A3").PasteSpecial (xlPasteAll)
    Application.CutCopyMode = False

where I have already set up the value of lastcell or is their a smarter way to do it?
 

Hoggle

New Member
Joined
Jan 21, 2008
Messages
43
To answer my own last query this doesn't work as I get a type mismatch error 13. I can always delete the row I don't want when the comments are all copied over.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,509
Messages
5,596,566
Members
414,078
Latest member
Frills

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
Top