I have been using it a lot (VBA) lately, and I've found that if you are using it for coding it's great for simple things. But if the situation gets a bit complicated you send a lot of time rephrasing the question, or debugging the code. How you ask the questions is important. The big advantage so far is that you don't have to do all the typing, which reduces spelling errors nad saves time. But you spend a lot of time arguing with it when things get complicated. I know about programming, but fairley new to VB, here si a subroutine that was produced buy ChatGP4.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
' Check if double-clicked cell is in Column M (8)
If Target.Column = 8 Then
If Target.Column = 8 And Target.Worksheet.Name = "CallLog" Then ' Column H in CallLog sheet
Dim response As VbMsgBoxResult
response = MsgBox("Do you want to continue?", vbYesNo)
If response = vbNo Then Exit Sub
Dim phoneNum As String
phoneNum = Target.Value
Dim lastRow As Long
lastRow = Sheets("DemandData").Cells(Rows.Count, "A").End(xlUp).Row
Dim firstRow As Long
firstRow = Target.Row
Do While firstRow > 1 And Sheets("CallLog").Cells(firstRow - 1, "H").Value = phoneNum
firstRow = firstRow - 1
Loop
Dim i As Long
Dim prevPhoneNum As String
prevPhoneNum = ""
For i = firstRow To Sheets("CallLog").Cells(Rows.Count, "H").End(xlUp).Row
If Sheets("CallLog").Cells(i, "H").Value <> phoneNum And prevPhoneNum <> "" Then
' Set the phone number for the current line as the previous phone number for the next group
prevPhoneNum = phoneNum
phoneNum = Sheets("CallLog").Cells(i, "H").Value
ElseIf Sheets("CallLog").Cells(i, "H").Value = phoneNum Then
Sheets("DemandData").Range("A" & lastRow + 1).Value = phoneNum
Sheets("DemandData").Range("B" & lastRow + 1).Value = Sheets("CallLog").Cells(i, "I").Value ' Column I in CallLog sheet
Sheets("DemandData").Range("C" & lastRow + 1).Value = Sheets("CallLog").Cells(i, "J").Value ' Column J in CallLog sheet
lastRow = lastRow + 1
End If
'Debug.Print i
Next i
SortDemandData firstRow + 1, lastRow ' Sort only the new data
Sheets("DemandData").Activate
End If
ColorGroups
' Cancel the default action of the event
Cancel = True
' Check if double-clicked cell is in Column M (13)
ElseIf Target.Column = 13 Then
Dim wsCallLog As Worksheet
Dim wsNotes As Worksheet
'Dim lastRow As Long
Dim phoneNumber As String
Dim newRow As Long
Dim matchFound As Boolean
'Dim i As Long
'Define worksheet objects
Set wsCallLog = ThisWorkbook.Worksheets("CallLog")
Set wsNotes = ThisWorkbook.Worksheets("Notes")
'Check if double-click occurred in Notes column (M)
If Target.Column = 13 Then 'Column M = column 13
'Get value in VPhonenumber column of the same row
phoneNumber = wsCallLog.Cells(Target.Row, 8).Value
'Check if value in column H of CallLog matches anything in column A of Notes
matchFound = False
For i = 1 To wsNotes.Cells(wsNotes.Rows.Count, 1).End(xlUp).Row
If wsNotes.Cells(i, 1).Value = phoneNumber Then
matchFound = True
'Position cursor on matching row and column B (ExtNotes)
Application.GoTo wsNotes.Cells(i, 2), True
Exit For
End If
Next i
'If match is found, activate Notes worksheet and position cursor on matching row
If matchFound Then
wsNotes.Activate
Application.GoTo wsNotes.Cells(i, 1), True
Else 'If no match is found, copy value to first open row in Column A of Notes sheet
lastRow = wsNotes.Cells(wsNotes.Rows.Count, 1).End(xlUp).Row
newRow = IIf(lastRow < 1, 1, lastRow + 1)
wsNotes.Cells(newRow, 1).Value = phoneNumber
'Position cursor on column B (ExtNotes) of new row
Application.GoTo wsNotes.Cells(newRow, 2), True
wsNotes.Activate
End If
'Cancel double-click event to prevent cell editing
Cancel = True
End If
' Cancel the default action of the event
Cancel = True
End If
End Sub
It was created for EXCEL, but it can be impressive when it wants to. Never would have created the sub without the help ChatGP4. Note that it took a lot of questions before it worked. Many hours.