Any error message?
You might get more interest if you include more details in the title of your question too!
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Macro is not running - What am I doing wrong?
Public Static Sub Comments()
Dim DataRange As Range
Dim LastRow As Long
Dim Count As Integer
Dim Cnt2 As Integer
Dim PresalesDelivery As Integer
Dim col As Long
Dim row As Long
Dim answ As Integer
Dim cmt As Comment
Dim phrase, Name, chkphrase, word, temp 'As String
LastRow = 765 'May change if Rows are added [was:294]
Count = 99
phrase = ""
chkphrase = "Master Presales Delivery Blank"
word = ""
temp = ""
PresalesDelivery = 1
Set DataRange = Range("A4:N" & LastRow)
Worksheets("Presales").Range("D4:N765").ClearComments 'Clear old Comments
Worksheets("Delivery").Range("D4:N765").ClearComments 'Clear old Comments
Application.ScreenUpdating = False
For Each ws In Worksheets
phrase = ws.Name
If Left(phrase, 5) = "Blank" Then
phrase = "Blank"
End If
Count = InStr(1, chkphrase, phrase, 1)
If Count = 0 Then 'Process
col = 4 'D or 4
row = 4
answ = 0
Sheets(PresalesDelivery).Activate
For row = 4 To LastRow 'Read row (4-30) Test:10-16
If Len((Cells(row, 3).Value)) > 1 Then 'If Col 3 header Blank, skip
For col = 4 To 14
answ = Cells(row, col).Value
If answ = 1 Then
'Sheets(2).Activate
If PresalesDelivery = 1 Then
Sheets("Presales").Activate
Else
Sheets("Delivery").Activate
End If
ActiveSheet.Cells(row, col).Select
If ActiveCell.Comment Is Nothing Then
ActiveCell.AddComment Text:="1-" & Name & Chr(10)
Else
phrase = ActiveCell.Comment.Text
Cnt2 = ((UBound(Split(phrase, Chr(10)))) + 1)
phrase = (phrase & Cnt2 & "-" & Name & Chr(10))
ActiveCell.Comment.Text Text:=phrase
End If
ActiveCell.Comment.Shape.TextFrame.AutoSize = True
Sheets(Name).Activate
ActiveSheet.Cells(row, col).Select
Exit For 'flag found, get out
End If
Next 'Col
End If
Next 'Row
End If
Next ws
Application.ScreenUpdating = True
If PresalesDelivery = 1 Then
Sheets("Presales").Activate
Else
Sheets("Delivery").Activate
End If
ActiveSheet.Cells(1, 2).Select
Worksheets("Presales").Range("A2").Value = "(c) 7'19"
Worksheets("Delivery").Range("A2").Value = "(c) 7'19"
MsgBox "Done..."
End Sub
Any error message?
You might get more interest if you include more details in the title of your question too!