Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

How to start running macro after filling values to some boxes?

0

I want to run the list toptobottom descending macro automatically after I filled the column, if there is an empty box in that column the macro will not start.

So the code should explain something like check the boxes, if not empty (or some other options like,if the sum is over or under this value) then run the macro.. 

Answer
Discuss

Discussion

Every Excel project consist of a design phase and an automation phase. Since the design must suit the intended automation method it's usual that it will be modified in the course of implementing automation. In your case automation is impossible because no workbook design exists (or is published).
Every automation is linked to a work process because it's the process that is being automated. You chose to describe the logic by which the code should work instead of the logic by which the user does. This is like the driver telling the mechanic how to repair the car. It won't work.
Finish your workbook design and publish your workbook. Complete your work flow design and make a detailed description of it part of your question.
Variatus (rep: 4889) Apr 12, '19 at 12:56 am
Finish the logic and design of how it should work and then attack the problem in pieces and it will be easier to help :)
don (rep: 1989) Apr 12, '19 at 3:10 am
What Variatus and Don say is spot on. That being said, the following may help you find the answer you are looking for. Add the following code to the WorkSheet code window for the sheet you need to apply this to.
Private Sub Worksheet_Change(ByVal Target As Range)
 
' macro written by WillieD24, Sept. 2020
 
' if there are no empty cells in specified range then call (run) your macro
 
Dim Last_Row As Integer   ' the number of the last used row in the spacified range
Dim Empty_Cells As Integer   ' the number of empty cells in the specified range
 
' select the sheet you want to run this code on
' Sheets("Sheet2").Select
 
' find the last row with data
Last_Row = Cells(Cells.Rows.Count, "A").End(xlUp).Row   ' edit "A" to the column of your choice
 
' count the number of empty cells in the range
Empty_Cells = WorksheetFunction.CountBlank(Range("A1:A" & Last_Row))
 
' simple code to verify check is working correctly
Cells(3, 3) = Empty_Cells   ' edit Cells(3, 3) to any not used cell on the sheet
 
' if there are no empty cells then call your TopToBottom macro to run
' un-comment next line after editing
' If Empty_Cells <> 0 Then Call TopToBottom   ' edit TopToBottom to whatever your macro name is
 

End Sub


Cheers   ;-}
WillieD24 (rep: 557) Sep 12, '20 at 8:43 pm
Add to Discussion



Answer the Question

You must create an account to use the forum. Create an Account or Login