PasteFormat into Columns if Condition is Met

ricardo9316

New Member
Joined
Apr 17, 2014
Messages
22
So guys, I am trying to tell VBA to Paste Format over every column if the condition is met within the Range (C1:N1) equalizing to 1.

I've this script working for Grouping Columns in other reports but I cant figure out how to tell it to do PasteFormat instead.


Columns("Z").Select
Selection.Copy


Dim c As Range

For Each c In Range("C1:N1")
If c.Value = "1" Then c.EntireColumn.Select
Selection.Paste

Next c
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
try this,

Code:
Sub Macro1()

Columns("Z:Z").Copy

For Each c In Range("C1:N1")

If c.Value = 1 Then

c.Columns.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If

Next c
End Sub

hth,
Ross
 
Last edited:
Upvote 0
Thanks Ross,

I keep getting this excel issue when trying to run.

"you can't paste this here because the copy area and paste area aren't the same size"

Is there another way to write the script to bypass this? Maybe instead applying against entire Columns we can try applying to ranges within the columns aligned with the cells that meet the condition.

I'll say that I tried to apply with script to a new blank sheet thinking there might be something hidden in my current worksheet but still get the same issue in return
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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