Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

excel - How to create 1000 macro buttons without creating each one individually

I'm working on a project for work and the last piece of the puzzle is creating a macro button on the end of each row. The macro will move the info to a second sheet and clear the info entered on the first sheet.

I need this for 1000 rows, is there a way to create 1000 macros that are only formatted for the row they are attached to?

I created the code below using the record button in Excel, I'm very new to VBA so any advice would be gladly appreciated it!

UPDATED VBA!

Dim Cell As Range
With Sheets(1)
      For Each Cell In .Range("H2:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
        If Cell.Value = "Completed" Then

            .Rows(Cell.Row).Copy Destination:=Sheets(2).Rows(Cell.Row)
            .Rows(Cell.Row).SpecialCells(xlCellTypeConstants).ClearContents
        End If
    Next Cell
End With

End Sub
question from:https://stackoverflow.com/questions/65877644/how-to-create-1000-macro-buttons-without-creating-each-one-individually

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...