L
L. Howard
This is two of seven macros I am writing to do the exact same thing to seven different columns, G to M.
The greatest difference between them is the column B source for the comments text values, which are in blocks of seven rows on sheet "Comments". (A number in column B is the key to grab the Offset(,1) for the comment text back to sheet "Application" and the proper column & cell.
I have intended to run all seven from a single button using an Input box and a Select Case scenario. Input the column letter and call the proper macro. (the OP sent me a workbook with seven buttons, one at the top of each column thinking that is how it has to be)
I suppose a pro could write a single macro that would take the column letter input and do what I am doing with seven. I am not opposed to that but I feel I need to be able to at least read and understand enough of the code to make adjustments and explain it to a moderate degree.
Your thoughts, please. Should I stay with the Select Case, which I know I can do?
Thanks,
Howard
Sub MyCommentMakerG()
Dim c As Range, i As Range
Dim lrg As Long
Dim Grng As Range, GrngC As Range
lrg = Sheets("Application").Cells(Rows.Count, 7).End(xlUp).Row
Set Grng = Sheets("Application").Range("G6:G" & lrg)
Set GrngC = Sheets("Comments").Range("B2:B8")
For Each c In Grng
'MsgBox c.Value
For Each i In GrngC
If i = c Then
c.ClearComments
c.AddComment
c.Comment.Visible = False
c.Comment.Text Text:=i.Offset(, 1).Text
End If
Next
Next
End Sub
Sub MyCommentMakerH()
Dim c As Range, i As Range
Dim lrh As Long
Dim Hrng As Range, HrngC As Range
lrh = Sheets("Application").Cells(Rows.Count, 8).End(xlUp).Row
Set Hrng = Sheets("Application").Range("H6:H" & lrh)
Set HrngC = Sheets("Comments").Range("B9:B15")
For Each c In Hrng
'MsgBox c.Value
For Each i In HrngC
If i = c Then
c.ClearComments
c.AddComment
c.Comment.Visible = False
c.Comment.Text Text:=i.Offset(, 1).Text
End If
Next
Next
End Sub
The greatest difference between them is the column B source for the comments text values, which are in blocks of seven rows on sheet "Comments". (A number in column B is the key to grab the Offset(,1) for the comment text back to sheet "Application" and the proper column & cell.
I have intended to run all seven from a single button using an Input box and a Select Case scenario. Input the column letter and call the proper macro. (the OP sent me a workbook with seven buttons, one at the top of each column thinking that is how it has to be)
I suppose a pro could write a single macro that would take the column letter input and do what I am doing with seven. I am not opposed to that but I feel I need to be able to at least read and understand enough of the code to make adjustments and explain it to a moderate degree.
Your thoughts, please. Should I stay with the Select Case, which I know I can do?
Thanks,
Howard
Sub MyCommentMakerG()
Dim c As Range, i As Range
Dim lrg As Long
Dim Grng As Range, GrngC As Range
lrg = Sheets("Application").Cells(Rows.Count, 7).End(xlUp).Row
Set Grng = Sheets("Application").Range("G6:G" & lrg)
Set GrngC = Sheets("Comments").Range("B2:B8")
For Each c In Grng
'MsgBox c.Value
For Each i In GrngC
If i = c Then
c.ClearComments
c.AddComment
c.Comment.Visible = False
c.Comment.Text Text:=i.Offset(, 1).Text
End If
Next
Next
End Sub
Sub MyCommentMakerH()
Dim c As Range, i As Range
Dim lrh As Long
Dim Hrng As Range, HrngC As Range
lrh = Sheets("Application").Cells(Rows.Count, 8).End(xlUp).Row
Set Hrng = Sheets("Application").Range("H6:H" & lrh)
Set HrngC = Sheets("Comments").Range("B9:B15")
For Each c In Hrng
'MsgBox c.Value
For Each i In HrngC
If i = c Then
c.ClearComments
c.AddComment
c.Comment.Visible = False
c.Comment.Text Text:=i.Offset(, 1).Text
End If
Next
Next
End Sub