Making code run when all cells in a range contain anything

Lobsterboy1

Board Regular
Joined
Aug 5, 2016
Messages
90
Hi,

I am trying to make a macro run when all cells in a range (E2:G2) contain any value. E2 will be a date typed in manually F2 and G2 will be picked from a drop down list.

Here is my code
Code:
Sub add_rows_at_top()
 With Application
         .Calculation = xlCalculationManual
         .ScreenUpdating = False
    Range("a2").EntireRow.Insert
    Range("a3").EntireRow.Copy
    Range("a2").PasteSpecial xlPasteAll
    Rows("2").EntireRow.ClearContents
    Range("A3:C12").Select
    Selection.Cut
    Range("A2").Select
    ActiveSheet.Paste
        .Calculation = xlCalculationAutomatic
         .ScreenUpdating = True
  End With
End Sub

The code is probably not the best but I am open to changing it to something neater.

Here is my sheet.

Skills log

*ABCDEFG
1NAMEDATE OF LAST TRAININGNO OF RECORDS*DATE OF TRAININGNAME SKILL
2J.Smith00/01/19000****
3A.Sugar00/01/19000****
4N.Mansell00/01/19000****
5A.Shearer00/01/19000****
6T.Hardy00/01/19000****
7*******
8*******
9*******
10*DATES HIGHLIGHTED RED IF OVER 30 DAYS SINCE LAST TRAINING RECORD*****
11******
12******

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:148px;"><col style="width:144px;"><col style="width:117px;"><col style="width:64px;"><col style="width:106px;"><col style="width:218px;"><col style="width:187px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B2{=MAX(IF(A2=F:F,E:E))}
C2=COUNTIF($F$2:$F$5001,A2)
B3{=MAX(IF(A3=F:F,E:E))}
C3=COUNTIF($F$2:$F$5001,A3)
B4{=MAX(IF(A4=F:F,E:E))}
C4=COUNTIF($F$2:$F$5001,A4)
B5{=MAX(IF(A5=F:F,E:E))}
C5=COUNTIF($F$2:$F$5001,A5)
B6{=MAX(IF(A6=F:F,E:E))}
C6=COUNTIF($F$2:$F$5001,A6)

<tbody>
</tbody>
Formula Array:
Produce enclosing
{ } by entering
formula with CTRL+SHIFT+ENTER!

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

Basically what I am wanting to do is

1, Have cells E2:G2 empty.
2, When I enter a date in E2, Pick from the drop down lists in F2 and G2. once all 3 of these cells are complete the code runs.
3, The code adds a new row between rows 1 and 2 and makes ready for the next entry.

This instead of when there are a lot of entries scrolling down hundreds of lines to add the next entry, the latest ones are always near the top.

Cheers for any help.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top