Macro modification

khanaran

New Member
Joined
Oct 24, 2012
Messages
20
Greetings

I have a macro that was written for me and it works perfect, however I tried to modify the macro to add two more line to copy and am stuck. Help and advice will be most highly appreciated

Rich (BB code):
     <code>
Option Explicit

Sub UpdateTable()
Dim LR As Long
With ActiveSheet
    If .[C2] = .[C6] And .[D2] = .[D6] And .[E2] = .[E6] And .[F2] = .[F6] Then
        MsgBox "It appears the current values have already be entered into row 6.  Aborting..."
        End
    End If
    LR = .Range("D" & .Rows.Count).End(xlUp).Row
    .Range("C6:F" & LR).Copy
    .Range("C7").PasteSpecial xlPasteValues
    .Range("C6:F6").Value = .Range("C2:F2").Value
      
    LR = WorksheetFunction.Max(.Range("I" & .Rows.Count).End(xlUp).Row, .Range("J" & .Rows.Count).End(xlUp).Row, .Range("K" & .Rows.Count).End(xlUp).Row)
    .Range("I6:K6").Copy
    .Range("I7").PasteSpecial xlPasteValues
    .Range("I6:K6").Value = .Range("D2:F2").Value
    .Range("o18:q18").Value = .Range("D2:F2").Value
    .Range("t18:v18").Value = .Range("D2:F2").Value
    .Range("x18:z18").Value = .Range("D2:F2").Value
    .Range("x19:z19").Value = .Range("o22:q22").Value
    .Range("x20:z20").Value = .Range("t22:v22").Value
End With

End Sub</code>

the blue shaded area is where I require help with

I need to copy the values from o22:q22 to x18:z18
and the values from t22:v22 to x20:z20


Thank you in anticipation for the help

Regards

raj
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi to all


my problem was highlighted to me and its working now perfectly

Thank you to all

Raj
 
Upvote 0
Cross-posted: Modify macro to copy data [SOLVED]

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #13 here: Forum Rules).

This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

For a more complete explanation on cross-posting, see here: Excelguru Help Site - A message to forum cross posters).
 
Upvote 0
Solution

Forum statistics

Threads
1,214,606
Messages
6,120,492
Members
448,967
Latest member
visheshkotha

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