rdy123 rdy
asked on
autofill formulas using macro
Hi,
I have data in C to G columns and formulas in A,B columns. And i paste the data in C-G columns everytime below the last pasted data, so when i paste the data i want the formulas to autofill in A&B columns using macro.
Kindly please suggest.
Regards,
Shamili
I have data in C to G columns and formulas in A,B columns. And i paste the data in C-G columns everytime below the last pasted data, so when i paste the data i want the formulas to autofill in A&B columns using macro.
Kindly please suggest.
Regards,
Shamili
Assuming your formulas in column A:B start from Row2, place the code given below on the Sheet Module.
To do so, right click the Sheet Tab --> View Code --> Paste the code given below into the opened code window.
So that when you paste your data in column C:G, the formulas in column A:B will be filled down the rows automatically.
To do so, right click the Sheet Tab --> View Code --> Paste the code given below into the opened code window.
So that when you paste your data in column C:G, the formulas in column A:B will be filled down the rows automatically.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Long
Application.EnableEvents = False
If Not Intersect(Target, Range("C:G")) Is Nothing Then
lr = ActiveSheet.UsedRange.Rows.Count
Range("A2:B2").AutoFill Range("A2:B" & lr), xlFillDefault
End If
Application.EnableEvents = True
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI Neeraj,
Thank you for your response, can this be added in modules?
i think it cant be added,kindly assist.
Thank you for your response, can this be added in modules?
i think it cant be added,kindly assist.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much for your inputs,it worked.
You're welcome. Glad it worked.
Please post your sample data with formula you are using for A & B Column