How can I edit this so it does it over Many Columns

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I have this code that works great
But instead of just working for column "CF"
I'd like it to do the same but for "CF:CO"
how can I get it to do this?

Code:
Sub TestNames1()
Lastrow = Sheets("Project Calendar Raw").Cells(Rows.Count, "A").End(xlUp).Row
For thisRow = 2 To Lastrow
Sheets("Names").Range("A" & thisRow & ":W" & thisRow).Value = Sheets("Project Calendar Raw").Range("A" & thisRow & ":W" & thisRow).Value
Sheets("Names").Range("X" & thisRow & ":Y" & thisRow).Value = Sheets("Project Calendar Raw").Range("X" & thisRow & ":Y" & thisRow).Value
Sheets("Names").Range("Z" & thisRow).Value = Sheets("Project Calendar Raw").Range("CF" & thisRow).Value
Next thisRow
End Sub



So basically once its done a list for CF it move onto the next column and does the same again hope that's clear?

Thanks

Tony
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
How about
Code:
Sub Tonywatson()
   Dim LastRow As Long
   With Sheets("Project Calendar Raw")
      LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
      Sheets("Names").Range("A2:A" & LastRow).Resize(, 26).Value = .Range("A2:Z" & LastRow).Value
      Sheets("Names").Range("Z2:Z" & LastRow).Resize(, 10).Value = .Range("CF2:CO" & LastRow).Value
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

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