LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Advice on multiple macros, same code just a different column

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice on learning VBA & macros from scratch slikk New Users to Excel 0 February 15th 11 10:49 PM
Advice on code Les Excel Programming 2 May 19th 08 04:03 PM
Advice on code Greg[_27_] Excel Programming 0 May 10th 06 04:48 PM
Need some advice on the following code Dean[_9_] Excel Programming 3 March 3rd 06 01:01 AM
Advice sought: Multiple column sorting davidm Excel Worksheet Functions 3 July 29th 05 02:06 PM


All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"