Macro help running a macro from macro

pedro-egoli

Well-known Member
Joined
Apr 25, 2004
Messages
1,217
Office Version
  1. 2016
Platform
  1. Windows
Some assistance please

This macro deletes all entries that are not on the half hour, and deletes date from date and time which are imported,
Works if I manually run it by clicking on bottom cell and selecting Macro/run blah.

Code:
Sub blah()
For rw = ActiveCell.Row To 4 Step -6
     Range(Cells(rw - 1, 1), Cells(rw - 5, 1)).EntireRow.Delete
Columns("A:A").NumberFormat = "[$-409]h:mm AM/PM;@"

Next rw
End Sub

I am trying to have the macro automatically run by use of this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r = Range("A1:A100")
If Intersect(t, r) Is Nothing Then Exit Sub
Application.EnableEvents = False
Callblah
Application.EnableEvents = True
End Sub

However, am unable to do so with the “callblah” being problem.
Once this is sorted I would like a chart to be introduced from columns A & B after original macro runs.
A holds time and B data applicable at that time.

Thanks

Pedro
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
There should be a space between Call and blah
 
Upvote 0
Thanks for that wigi, it worked.

However, it raised another problem.

The data imported is to do with solar generation and comes from a chart which I access through inverter software linked to my computer.
It starts running early morning and does not really start producing until about 7 am.
This is the info early am that is imported

Excel Workbook
ABC
1DateToday Energy[Wh]*
203-08-11 5:260*
303-08-11 5:310*
403-08-11 5:360*
503-08-11 5:410*
603-08-11 5:460*
703-08-11 5:510*
30811


The zero production today continued to 6.51am (row 19) and apparently continues after file has been saved as when I selected the cell to delete (to run macro) it was in cell A174 (7.48PM)
This is because I need to leave inverter running so chart is not lost.
Sometimes I do the import early sometimes late.

Anyway what happens now after successfully having deletion automatic run I went back to get rid of the various cells that had continued repeating since inverter stopped producing.
This triggered the macro to run again and it deleted most of the data.

So the question at this stage is can the automatic start be limited to one run only and , if so , how do I stop the macro.

Thanks and I hope I haven't confused you too much

Pedro
 
Upvote 0
Thought I had go it sorted by deleting all early morning balances with a zero and afternoon ones where numbers had been repeated.

I got the macro to run several times as I was trying to fine tune sheet and then suddenly I got a Run time error 1004 , with the line " Range(Cells(rw - 1, 1), Cells(rw - 5, 1)).EntireRow.Delete" highlighted .

To check what the problem was I stopped the debugger and the macro had in fact run and I was able to insert a chart.

However, when I repeated the same steps and went to delete a cell which had previously triggered the macro nothing happened.

Checked again with morning and afternoon balances unchanged and it worked again.

Is it one of those mysteries of life or what.

Is it possible to tweak the code which deletes rows to show only data on the half hour to also include deletion of any cell in column B with a zero as well as any times after say 5pm.
Alternatively if it could change to start 7am and finish 5 pm that would also do the job.

Present code is here
Code:
Sub blah()
For rw = ActiveCell.Row To 4 Step -6
     Range(Cells(rw - 1, 1), Cells(rw - 5, 1)).EntireRow.Delete
Columns("A:A").NumberFormat = "[$-409]h:mm AM/PM;@"

Next rw
End Sub

Thanks

Pedro
 
Upvote 0
BUMP

In particular
Code:
s it possible to tweak the code which deletes rows to show only data on the half hour to also include deletion of any cell in column B with a zero as well as any times after say 5pm.
Alternatively if it could change to start 7am and finish 5 pm that would also do the job.

Pedro
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,470
Members
452,915
Latest member
hannnahheileen

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