Not coming from a VBA background I am trying to put together something quite simple, but I am struggling to do it. I have a spread sheet with numerous sheets within it containing accounts to sales people mappings. What I am trying to do is have the user choose a staus of "Send to Free Pool" in the "H'' column, the row is copied to a sheet called "Free Pool''. Once this process is complete the cell row must be deleted on the source worksheet. I have managed to get the move process to work, but it keeps on pasting the copied row to line 30, and continually overwrites the data as each row's satus is set, or ignores the FinalRow command and pastes it anywhere it likes.
Below is my VB script that I have cobbled together from a few sources (for ease of troubleshooting Sheet1 = Free Pool in the code below
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("Sheet1").Select
' Find the last row of data
Dim FinalRow As Long
FinalRow = Range("A65536").End(xlUp).Row
'Dim nextrow As Long
'nextrow = Range("A65536").End(xlUp).Row
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
If Not Intersect(Target, Range("H7:H" & Cells(Rows.Count, "H").End(xlUp).Row)) Is Nothing Then
If Target.Value = "Send to Free Pool" Then
Range("A" & Target.Row & ":I" & Target.Row).Copy Destination:=Sheet1.Range("A" & FinalRow)
'Target.EntireRow.Delete
End If
End If
Application.ScreenUpdating = False
End Sub
Once I have this sorted I'm trying to figure out the best way to set the "H" column on the "Free Pool"" worksheet only, to active and the Macro asks which worksheet it should be copied to and performs the neccessary actions similar to the above code.
Any help would be greatly apreciated
Thanks
Andrew
Below is my VB script that I have cobbled together from a few sources (for ease of troubleshooting Sheet1 = Free Pool in the code below
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("Sheet1").Select
' Find the last row of data
Dim FinalRow As Long
FinalRow = Range("A65536").End(xlUp).Row
'Dim nextrow As Long
'nextrow = Range("A65536").End(xlUp).Row
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
If Not Intersect(Target, Range("H7:H" & Cells(Rows.Count, "H").End(xlUp).Row)) Is Nothing Then
If Target.Value = "Send to Free Pool" Then
Range("A" & Target.Row & ":I" & Target.Row).Copy Destination:=Sheet1.Range("A" & FinalRow)
'Target.EntireRow.Delete
End If
End If
Application.ScreenUpdating = False
End Sub
Once I have this sorted I'm trying to figure out the best way to set the "H" column on the "Free Pool"" worksheet only, to active and the Macro asks which worksheet it should be copied to and performs the neccessary actions similar to the above code.
Any help would be greatly apreciated
Thanks
Andrew