Forum Discussion

Atli-369's avatar
Atli-369
Copper Contributor
Feb 24, 2022

VBA code help

Hi There,


I am attempting to create a vba code that copies & paste two separate ranges from two columns to two separate ranges and columns in the same worksheet when the value in one cell(AH1) changes. The value changes each week day. The worksheet attached is covers a one week period ). I am a "new kid on the VBA block, and am stuck. I am using the following to start:

 

Private Sub Worksheet_SelectionChange(ByVal Target As range)

Dim range1 As range
Set range1 = Sheet1.range("AH69")

If range1.Value = 1.1 Then
Call Week1SGLevelsD1

End If

Macro:

Sub Week1SGLevelsD1()

range("C71:C84").Value = range("AG71:AG84").Value


End Sub

What I wish to do is change the macro to copy two separate ranges(AG71:AG84) & (AH71:AH84) and paste to two different ranges(C71:C84 & E71:E84).  This represents one days data change.  I am using a different value in the source cell(AH69) (e.g.1.1,1.2 ect. for the respective days data change). I would like to shorted the whole process, if possible for the entire month.  Right now I would have to create 5 macros to call per week and 20 if/then routines.  Any suggestions would be appreciated.

 

Sincerely,

-JP

 

No RepliesBe the first to reply