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
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,617
Members
449,039
Latest member
Mbone Mathonsi

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
Back
Top