VBA help

Corkeyed

New Member
Joined
Dec 17, 2021
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hi,
I'm very new to VBA and Excel macros and I'm hoping someone can assist me. I'm looking for a VBA script that:
  1. Copies the current sheet
  2. Adds 7 days to two different cells (C7 and F7)
  3. Renames the sheet based on the new value of F7
Any help would be greatly appreciated!

Thanks,
C
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Are C7 and F7 Excel date values (and not just text that looks like a date)?

What is the format for the new sheet name?
 
Upvote 0
You might consider the following...

VBA Code:
Sub CopySheet()
Dim ws1 As Worksheet
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
Set ws1 = ActiveSheet
With ws1
    .Range("C7") = .Range("C7") + 7
    .Range("F7") = .Range("F7") + 7
    .Name = Format(.Range("F7").Value, "mm-dd-yyyy")
End With
End Sub

Cheers,

Tony
 
Upvote 0
Solution
You might consider the following...

VBA Code:
Sub CopySheet()
Dim ws1 As Worksheet
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
Set ws1 = ActiveSheet
With ws1
    .Range("C7") = .Range("C7") + 7
    .Range("F7") = .Range("F7") + 7
    .Name = Format(.Range("F7").Value, "mm-dd-yyyy")
End With
End Sub

Cheers,

Tony
Worked a charm! Thanks for your help on this!
 
Upvote 0
You're very welcome.

Happy Holidays!
 
Upvote 0

Forum statistics

Threads
1,214,887
Messages
6,122,095
Members
449,064
Latest member
Danger_SF

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