PDA

View Full Version : Please help _table update



reda
10-03-2016, 08:10 AM
Please help me in coding , my question is clearly explained in the attached excel file.

YasserKhalil
10-03-2016, 01:34 PM
Hello Reda
Copy range C4 to D8 in sheet2 for example
Put the following code in worksheet module


Private Sub Worksheet_Change(ByVal Target As Range)
Dim Lr As Long

If Not Intersect(Target, Range("C4:D" & Cells(Rows.Count, 3).End(xlUp).Row + 1)) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Lr = Cells(Rows.Count, 3).End(xlUp).Row
Range(Cells(Target.Row, 3), Cells(Target.Row, 4)).Copy Range("XFC" & Lr + 1)
Range("XFC5:XFD" & Lr + 1).Sort Key1:=Range("XFC5:XFC" & Lr), Order1:=xlAscending, Key2:=Range("XFD5:XFD" & Lr), Order2:=xlAscending, Header:=xlNo
Range("XFC4").CurrentRegion.Copy Range("C4")
Range("XFC4").CurrentRegion.ClearContents
Application.CutCopyMode = False
Application.EnableEvents = True
Application.ScreenUpdating = False
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C4:D" & Cells(Rows.Count, 3).End(xlUp).Row + 1)) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
Range("XFC4").CurrentRegion.ClearContents
Range("C4").CurrentRegion.Copy Range("XFC4")
Application.EnableEvents = True
Application.ScreenUpdating = False
End If
End Sub

reda
10-03-2016, 11:16 PM
Thank U man works fine.
But i want the update to be in new table
And how to modify yr code to make it for column E for example instead of column D

YasserKhalil
10-04-2016, 04:34 AM
You're welcome Reda
Try to read the lines of code. It is not complicated and try using F8 to run the code line by line to see how it works
And you will know how to edit it.
If it was difficult upload your file and It will be easy to apply the code to it

reda
10-04-2016, 08:01 AM
Much appreciated.
My table lookslike the attached sheet each cell contains a formula takes its value from another sheet.
How to apply the same code on my table , i try to use f8 but...
Plz help me in this.

YasserKhalil
10-04-2016, 03:13 PM
Do you need to deal with the whole range in your file?
You have told that there are formulas .. Where are they?

The file would express the original file ...

reda
10-07-2016, 03:05 AM
Exactly the whole range
My formula is long one it updated automatically from another workbook. so i made it simple with the same idea , i put formula on column H so stages takes thier value from this column.