Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Not sure if there is a solution to this problem or not, but here's what I'm attempting to do:
I've designed a worksheet in which users are able to add aditional rows to different categories by clicking on an "Insert Row" command button. Assigned macro reads as the following:
Sub Button44_Click()
Rows("28:28").Select
Selection.Insert Shift:=x1Down
End SubOn worksheets with only one category that may need additional rows, this works perfectly. However, on worksheets that include different categories (i.e. under colums B, C, D, etc.), I have multiple "Insert Row" command buttons. Problem is, once the command button at the top of the sheet is clicked (several times), it thows off all the other command buttons. For example, "Insert Row" #2 reads:
Sub Button45_Click()
Rows("35:35").Select
Selection.Insert Shift:=x1Down
End SubBut the problem is, once the first command button is used, the second command button is inserting rows on Row35, but should adjust to how many rows were inserted with the first command button (does this make sense?).
Again, I don't know if this is possible or not, but any help would be appreciated.

Well, one thing you could do is set up a counting cell off somewhere that the user won't see and increment it in your Button44 macro and then reset it with the Button45 macro.
A better way is to key off of information that is always in the workbook to find the appropriate row location for insertion. Something like the following:
Set NameAddress = Cells.Find(What:=KeyWord, after:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If NameAddress Is Nothing Then
MsgBox "Not found"
Else:
NextRow = NameAddress.Row + 1
MsgBox NextRow
End IfI did not test the above code, it is only provided as an example.

Thanks Lobster!
I had to tweak a little bit and change a few things around and play with it, but made it work perfectly! Thanks for the help.
GMP

FYI,
Used the following:
Set NameAddress = Cells.Find("INSERTYOURTEXTHERE", after:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
NameAddress.Select
ActiveCell.Offset(1, 0).EntireRow.InsertFor each of the command button macros I entered different combinations of text in cells that wouldn't be used by the individual (and protected them); as well as masked the text (font color = background color) so it is invisible to the user.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |