Hello. I am completly new to programming and VBA. I tried writing my first primitive macros from scratch and soon got into trouble, first with errors, then it didn't seem to do anything. I would greatly appreciate some advise or solutions from more experienced VBA users.
Here it is:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Application.ScreenUpdating = False
Application.EnableEvents = False
Sheets("HK-oppfolging").Activate
For Each Cell In Range("D4,D29,D54,D79,D104,D129,D154,D179,D205").Cells
If Cell.Text = Sheets("Status").Range("D7").Value Then
ActiveSheet.Range(Cells(-3, -2), Cells(3, 22)).Select
End If
Selection.Copy
Sheets("Status").Select
ActiveSheet.Range(Cells(2, 11), Cells(8, 35)).Select
Next Cell
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
What I have is two worksheets: "Status" and "HK-Oppfolging". "HK-oppfolging" constitutes of 9 tables stacked in an uniform pattern. In each of the 9 tables there is a name in one cell (D4,D29,D54,D79,D104,D129,D154,D179,D205)
The tables are in the range (-3collumns, -2rows): (3collums, 22rows) compared to the cell with the name: E.g. for D4, the range is A2:G26.
The worksheet "Status" cell D7 has a name.
Now, what I want the macro to do is to find the name in D7 wich will be in one of the "HK-oppfolging" sheet cells (D4,D29,D54,D79,D104,D129,D154,D179,D205) and when it finds it, then copy the corresponding table to the range B11:H35 in the worksheet "Status".
Anyone?
Here it is:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Application.ScreenUpdating = False
Application.EnableEvents = False
Sheets("HK-oppfolging").Activate
For Each Cell In Range("D4,D29,D54,D79,D104,D129,D154,D179,D205").Cells
If Cell.Text = Sheets("Status").Range("D7").Value Then
ActiveSheet.Range(Cells(-3, -2), Cells(3, 22)).Select
End If
Selection.Copy
Sheets("Status").Select
ActiveSheet.Range(Cells(2, 11), Cells(8, 35)).Select
Next Cell
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
What I have is two worksheets: "Status" and "HK-Oppfolging". "HK-oppfolging" constitutes of 9 tables stacked in an uniform pattern. In each of the 9 tables there is a name in one cell (D4,D29,D54,D79,D104,D129,D154,D179,D205)
The tables are in the range (-3collumns, -2rows): (3collums, 22rows) compared to the cell with the name: E.g. for D4, the range is A2:G26.
The worksheet "Status" cell D7 has a name.
Now, what I want the macro to do is to find the name in D7 wich will be in one of the "HK-oppfolging" sheet cells (D4,D29,D54,D79,D104,D129,D154,D179,D205) and when it finds it, then copy the corresponding table to the range B11:H35 in the worksheet "Status".
Anyone?