Using VBA to Copy Ranges to a PreSet Dim formula AND Cell Propertys.

O

omen666blue

Hi all, Im working on a Rotseirn form were i allow the user to buil
there own roster Just by inserting a number into a Cell and clicking
button. Iv got most of the way But just need the last few Bits.

Basically i Use Dim Sets at the start of my Macro that copy a templat
range and Then runs a loop depending on what the user has input into th
cell next to the button. I Have a Auto Fit command at the end of th
Loop that fixes one of my problems But what i would Like is for th
Macro to copy All the Cell Setting I.e Column Width+Height And Borders
and then to paste these in the Loop.

What iv got so far is this:
=======================================================
Sub Ne()
Dim E As Variant
Dim Name As Variant
Dim Count As Integer
Dim lastRow As Long
Count = 0
Count2 = 3

E = Worksheets("Template").Range("$B$3:$AD$3").Formula
Name = Worksheets("Sheet1").Range("$C$3")
Sheets.Add.Name = Name

Do Until Count = Worksheets("Sheet1").Range("$C$4")
If Count >= 1000 Then Exit Do
Count = Count + 1
Count2 = Count2 + 1
Worksheets(Name).Cells(Count2, "A") = Count
Worksheets(Name).Cells(Count2, "AE") = Count
Worksheets(Name).Range(Cells(Count2, "B"), Cells(Count2, "AD")) = E

Loop

Worksheets(Name).Range("A:AE").Columns.AutoFit

MsgBox ("The loop ran " & Count & " times.")

End Sub
=========================================================

Any Help Would Be much Appreciated.
I Have tried Adding Another Dim As so and Making its Value As Below
W = Worksheets("Template").Range("$B$3:$AD$3").Borders().LineStyle
Then Making the Cells W, To No Avail.

Thanks for taking the time to look!

Regards
chri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top