Simple Copy Paste Macro Not Working!!!! :@ :@ :@

HACZN12

New Member
Joined
Apr 20, 2017
Messages
14
I'm trying to create a simple macro, its not working and therefore driving me a bit crazy, all i'm aiming to do is:

If the value in the T/F record is set to true in the table 1 (listed below):


Table 1
No.1T/FPhone numberOther random infoContactPercentage
1TRUE20453534fdgeshshRandom name110%
2FALSE454354eghertgesrgRandom name120%
3FALSE24532534regergrgRandom name130%
4TRUE2435345ergsarRandom name140%
5TRUE234525ergertghrtRandom name150%
6FALSE425345erhwrhRandom name160%
7FALSE23452345erhwrehrthRandom name170%
8TRUE245254htrhgfbgbRandom name180%
9FALSE356364dfbfbfRandom name190%
10TRUE2452efgethgethethRandom name200%

<tbody>
</tbody>



I would like only the contact and percentage to be pulled through into table 2 (outlined below) upon activating the macro:


Table 2
No.1ContactPercentage
1
2
3
4
5
6
7
8
9
10

<tbody>
</tbody>




Table 2 resides on a separate worksheet, any help would be very much appreciated!


Let me know if you require further information and i'll elloborate!

Regards

H
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
How about
Code:
Sub CopyData()

   With Sheets("[COLOR=#ff0000]Summary[/COLOR]").Columns(2)
      .Replace False, "@", xlWhole, , False, , False, False
      With .SpecialCells(xlConstants, xlLogical)
         .Offset(, 3).Copy Sheets("[COLOR=#ff0000]New[/COLOR]").Range("B" & Rows.Count).End(xlUp).Offset(1)
         .Offset(, 4).Copy Sheets("[COLOR=#ff0000]New[/COLOR]").Range("C" & Rows.Count).End(xlUp).Offset(1)
      End With
      .Replace "@", False, xlWhole, , False, , False, False
   End With
End Sub
Changing sheets names in red to suit.
 
Upvote 0
That worked perfectly! Thank you words cannot express how long i've been scratching my head at this one!!! what if i however wanted to apply two criteria i.e. pulling through values where lets say T/F is True and the "Other Random Info" says "Red"?
 
Upvote 0
Like this
Code:
Sub CopyData()

   With Sheets("Summary")
      .Columns(2).Replace False, "@", xlWhole, , False, , False, False
      .Columns(4).Replace "[COLOR=#ff0000]Red[/COLOR]", True, xlWhole, , False, , False, False
      With .Columns(2).SpecialCells(xlConstants, xlLogical)
         .Offset(, 3).Copy Sheets("New").Range("B" & Rows.Count).End(xlUp).Offset(1)
         .Offset(, 4).Copy Sheets("New").Range("C" & Rows.Count).End(xlUp).Offset(1)
      End With
      With .Columns(4).SpecialCells(xlConstants, xlLogical)
         .Offset(, 1).Copy Sheets("New").Range("B" & Rows.Count).End(xlUp).Offset(1)
         .Offset(, 2).Copy Sheets("New").Range("C" & Rows.Count).End(xlUp).Offset(1)
      End With
      .Columns(2).Replace "@", False, xlWhole, , False, , False, False
      .Columns(4).Replace True, "[COLOR=#ff0000]Red[/COLOR]", xlWhole, , False, , False, False
   End With
End Sub
Changing the word red for whatever word you want
 
Upvote 0
Thank you! It was working great then when i tried run it this morning it said Run-time error '1004': No cells were found and the debugger points me to the third line of the script: With .SpecialCells(xlConstants, xlLogical)

Do you know what could be causing this?
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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