How do I post a stored range?

Gaark

New Member
Joined
Jul 9, 2014
Messages
3
Hello all!

I've been hunting around looking for a way to update my file and I need a bit of extra help please.

My file has 250+ sheets in it and the first 2 are the main index and the calculation information base, the rest of the sheets are of individual products which have their own values for pricing purposes. I have plans to upgrade the machinery I am working with which means I need to upgrade my pricing mechanism to accurately show what my costs will be based on the new machinery.

OK, the first 4 columns of each workings sheet are fixed and do not need changing.
12 more columns need inserting before column E
my named range needs to be pasted into the gap, and replace the existing 3 columns of pricing calculations.
Any data outside of these columns shouldn't be harmed except for T4 which has a little update.

This is what I have so far, but bugs out when it reaches the paste function because I don't know how to get it to paste "data":
Code:
Sub Macro6()
'
' Keyboard Shortcut: Ctrl+Shift+X
'
Dim sht As Worksheet
Dim data As range
Set data = range("3!E1:R29")


For Each sht In ActiveWorkbook.Worksheets
    Columns("E:O").Select
    range(Selection, Selection.Offset(0, 0)).Insert shift:=xlToRight
    range("e:s").Select
    ActiveSheet.Paste
    range("t4").Select
    ActiveCell.FormulaR1C1 = "=RC[-18]/9"
    Next sht
End Sub

Thanks for reading :)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
See if this will work:
Code:
Sub Macro6()
'
' Keyboard Shortcut: Ctrl+Shift+X
'
Dim sht As Worksheet
Dim data As Range
Set data = Range("3!E1:R29")
    For Each sht In ActiveWorkbook.Worksheets
        Columns("E:O").Select
        Range(Selection, Selection.Offset(0, 0)).Insert shift:=xlToRight
        data.Copy ActuveSheet.Range("E1")
        Range("t4").Select
        ActiveCell.FormulaR1C1 = "=RC[-18]/9"
    Next sht
End Sub
 
Upvote 0
maybe this
Code:
Sub Macro6()
'
' Keyboard Shortcut: Ctrl+Shift+X
'
Dim sht As Worksheet
Dim myrange As Range
Set myrange = Sheets("3").Range("E1:R29")


For Each sht In ActiveWorkbook.Worksheets
    With sht
    .Columns("E:O").Insert
    myrange.Copy sht.Range("E1")
    .Range("t4").FormulaR1C1 = "=RC[-18]/9"
    End With
    Next sht
End Sub
 
Upvote 0
Thanks JLG, the data range got pasted right where I wanted it.

One glitch that did pop up though, the sheet didn't increment and the macro magic on sheet "6" went through the 'insert, paste' loop a lot and I ended up with a sheet that went into column AXO and more LOL.

I've gone exploring and found what I needed to get the macro to do all that was needed, it involved making a new sheet that stored my source data.

This is what I ended up with:
Code:
Sub Macro6()
'
' Keyboard Shortcut: Ctrl+Shift+X
'
Dim sht As Integer
Dim data As range
sht = 4
Set data = range("SOURCE!h1:R29")


Do While sht < 10
    Sheets(sht).Select
        Columns("h:r").Select
        range(Selection, Selection.Offset(0, 0)).Insert shift:=xlToRight
        data.Copy ActiveSheet.range("h1")
        range("t4").Select
        ActiveCell.FormulaR1C1 = "=RC[-18]/9"
    sht = sht + 1
Loop
End Sub
 
Upvote 0
Great, but get rid of the Select.Selection lines
Code:
Sub Macro6()
'
' Keyboard Shortcut: Ctrl+Shift+X
'
Dim sht As Integer
Dim data As range
sht = 4
Set data = range("SOURCE!h1:R29")
Do While sht < 10
    Sheets(sht).Columns("h:r").Insert
        data.Copy ActiveSheet.range("h1")
        range("t4").FormulaR1C1 = "=RC[-18]/9"
    sht = sht + 1
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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