VBA - With each table on Activesheet

Finalfight40

Active Member
Joined
Apr 24, 2018
Messages
273
Office Version
  1. 365
Platform
  1. Windows
Hi

I am trying to set something up in VBA where it would cycle through each table on the Activesheet and if the 3rd column header says "Start Date" then add 7 for each element on the 3rd column of that table.

How would this be written in VBA?
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I have not been able to reproduce that error. Can you confirm the full error message?
.. on some sheets i am receiving a run time error '91'
This indicates that you are possibly running the code over more than one sheet. If so, perhaps you have modified the code in some way? If so, can you post the code that you are using?

One thing to note is that Evaluate can cause problems if the sheet it is supposed to be working on is not the active sheet, though I still wouldn't expect the error message that you have reported.
 
Upvote 0
Hi Peter

The only thing i added was something like:

Code:
Range("G1").select
Range("F1").select

at the end just so that it would run the on worksheet change event (or one of the events) afterwards.

I can repost when i get back into work.

However just as a quick test to recreate this error is to create a table and have 'Start Date' and the third table header. Don't enter anything into the table and try to run the code.
 
Upvote 0
However just as a quick test to recreate this error is to create a table and have 'Start Date' and the third table header. Don't enter anything into the table and try to run the code.
I had already done that after you first reported the error. That does not error for me & just leaves the table as it was.
 
Upvote 0
OK, thanks. I can now see what the problem is. Although I had not entered any data in my 'blank' table, my table did have a few (empty) rows. Your table has no "DataBodyRange" hence the code fails.
Try adding the blue code
Rich (BB code):
If LO.ListColumns.Count > 2 And LO.ListRows.Count > 0 Then
 
Upvote 0
Thank you for your help and time with this Peter. It seems this has now resolved my issue.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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