Dynamic Range VBA

Heathkleff

New Member
Joined
Jun 28, 2018
Messages
1
Hello guys,

We are using and old file for doing reporting every week, and this file contains many graphics. I am trying to improve this file by adding new graphic that uses data coming from the sheet "Zero Trafic" I recently created and that is updated every week by new data coming from an other file.

The idea is when I click on the button "Décaler sem +1", the new graphic should be updated and the graphic should contains only the data of the last 11 weeks (Sxx).

Here bellow the macro affected to the button "Décaler sem +1":

Sub DecalerPlageBAS()


'Dim Plage As Range
Dim Nm As Name


Application.ScreenUpdating = False

'On Error Resume Next


'Sheets.Add After:=ActiveSheet
'Range("A1").Select


'Boucle sur les noms du classeur
For Each Nm In ThisWorkbook.Names
If Nm <> "=#NAME?" Then
NOMPLAGE = Nm.Name
Range(Nm).Select
premierecellule = ActiveCell.Offset(Selection.Columns.Count - 1).Address
dernierecellule = ActiveCell.Offset(Selection.Rows.Count - 1).Address


premierecelluleV2 = Range(premierecellule).Offset(1, 0).Address
dernierecelluleV2 = Range(dernierecellule).Offset(1, 0).Address


'définition de ma plage
MaPlage = premierecelluleV2 & ":" & dernierecelluleV2

'Modification de la plage
With ActiveWorkbook.Names(NOMPLAGE)
.Name = NOMPLAGE
.RefersTo = "=Evolution!" & MaPlage
End With

' ActiveCell = Nm
'ActiveCell.Offset(1, 0).Select
End If
Next Nm


Range("A1").Select
ActiveSheet.Calculate




End Sub

And here bellow a sample of data contained in the sheet "Zero Trafic":

SemaineInférieur 3jrsSupérieur 3jrsSupérieur 1semSupérieur 2sem
S53319190300
S01293200250
S025952384111
S037252478410
S046223569822
S055522196412
S067263014411
S075072739412
S08606291785
S09459221897
S107541917725
S115262505123
S1266829910034
S139292808618
S147094429716
S1551023211435
S164141314314

<colgroup><col span="4"><col></colgroup><tbody>
</tbody>


Can you please give a help?

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Could you point your graphics information to a standard location and have your macro copy the last 11 weeks of data to the standard location. That way you would not need to update the graphic, just the info in the standard location.
 
Upvote 0

Forum statistics

Threads
1,215,409
Messages
6,124,733
Members
449,185
Latest member
hopkinsr

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