Caveman1957;1605554 said:
Thanks Mick.
I currently have a copy of the ParseData code under Private Su
Worksheet_Activate() with a check so it will only run if there is n
data in the sheet.
What I need now is a manual update option.
I did think about adding a dialog at the start of th
Worksheet_Activate() to ask if an update is required and then remove th
data exists check but I do not know how to do this.
I managed to get a dialog box designed with text and two option button
but how to get this to display and then receive the information on whic
button is pressed is beyond me. I was thinking that one button woul
return true and the other false.
Thanks to all who helped my brain get firing
Here is my current solution, which also has the manual update thin
fixed.
Code on the tab:
Private Sub Worksheet_Activate()
Dim Query As String
'This sub will copy all pertinent data from the SS tab and copy it t
current tab hopefully
If ActiveSheet.Cells(2, 1) = "" Then
ParseData
Else
'Ask whether to Update
Query = InputBox("Update Data? Y/N", "User Input")
If Left(Query, 1) = "Y" Or Left(Query, 1) = "y" Then
ParseData
Else
'Do Nothing
End If
End If
Application.ScreenUpdating = True
End Sub
Private Sub ParseData()
Dim lRow As Long
Dim sr As Long
Dim dr As Long
'This sub will copy all pertinent data from the SS tab and copy it t
current tab
Application.ScreenUpdating = False 'Speeds up macro
'Last row of data on SS tab Sheet8
lRow = Sheet8.Range("A3000").End(xlUp).Row
'Copy data to tabs (Note: only copying the pertinent columns)
'Sheet8 is SS
dr = 2
sr = 2
Do
If Sheet8.Cells(sr, 3).Value = CInt(Left(ActiveSheet.Name, 4)) And _
Sheet8.Cells(sr, 8).Value = "Yes" Then 'Check for VM user
Call PhoneDataCopy(sr, dr)
dr = dr + 1
sr = sr + 1
Else
sr = sr + 1
End If
Loop Until Sheet8.Cells(sr, 1) = "z"
Application.ScreenUpdating = True
End Sub
Then I have a module with the PhoneDataCopy function in it as follows:
Function PhoneDataCopy _
(ByVal Source_Row As LongPtr, ByVal Destination_Row As LongPtr)
Dim lsourceCol(1 To 5) As Integer
Dim ldestinationCol(1 To 5) As Integer
Dim x As Integer
'This sub will copy all pertinent Phone data from a row on SS tab an
copy it to a row on current tab
'Set the column references for the SS tab
lsourceCol(1) = 6 'MAC address
lsourceCol(2) = 7 'Full Name
lsourceCol(3) = 5 'NTID
lsourceCol(4) = 14 'E164 Extension Number
lsourceCol(5) = 15 'Line COS String
'Set the column reference number for the Phone Destination tab
ldestinationCol(1) = 1
ldestinationCol(2) = 2
ldestinationCol(3) = 4
ldestinationCol(4) = 5
ldestinationCol(5) = 6
'Copy data to tabs (Note: only copying the pertinent columns)
'Sheet8 is SS
For x = 1 To 5
Sheet8.Cells(Source_Row, lsourceCol(x)).Copy
ActiveSheet.Cells(Destination_Row, ldestinationCol(x)).PasteSpecia
(xlPasteValues)
Application.CutCopyMode = False
Next x
End Function
It could probably be tidied up but it does the job and I can tailor i
for the other tabs where the criteria are different.
Thanks again to all who replied
+-------------------------------------------------------------------
+-------------------------------------------------------------------