Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 14
Default Using VBA to Copy Ranges to a PreSet Dim formula AND Cell Propertys.

Hi all, Im working on a Rotseirn form were i allow the user to build there own roster Just by inserting a number into a Cell and clicking a 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 template range and Then runs a loop depending on what the user has input into the cell next to the button. I Have a Auto Fit command at the end of the Loop that fixes one of my problems But what i would Like is for the 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
chris
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to COPY FORMULA BETWEEN RANGES Randy Excel Discussion (Misc queries) 1 May 13th 10 02:20 PM
How do I copy formula but only increment certain ranges? Martc Excel Discussion (Misc queries) 8 February 4th 10 11:01 PM
how copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
UserForm questions about text box propertys, thanks pgarcia Excel Programming 3 February 21st 08 09:06 PM
How do I preset data to auto copy to a certain page wil4d Excel Discussion (Misc queries) 0 December 19th 05 11:35 PM


All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"