vba code to insert formula if cell is blank

dionisio lamas

New Member
Joined
Nov 16, 2022
Messages
3
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I am trying to create a table to grade tests.

In my worksheet "4" I have created a table (see picture, please) whose number of rows and columns vary according to the number of students and the number of questions.

I need a column, in my worksheet "4", that have the "autosum" for each row.... ("autosum" that I want to be inserted through a macro, triggered by a button).

I am trying to create a vba code that inserts the "autosum" function, and I am looking for this function to be inserted, for example, when row 5 is blank (to have some dynamism this way, since the number of questions is variable...)

As I am learning vba by myself, I haven't succeeded yet :(

Could you please help me?

Thank you
 

Attachments

  • ajuda xls.jpg
    ajuda xls.jpg
    164.3 KB · Views: 7

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Do you mean the number of columns can be variable? (rows have the students on it).

Whilst you could do something in VBA you might be overcomplicating it, if the cell is blank the autosum will effectively ignore that cell.
 
Upvote 0
HI RockEd,

Thanks for your reply!

In fact the number of rows could be variable (and the number of students too, since I have several classes, and I need to grade them)

Perhaps I'm overcomplicating... But I would like to surpass the chalange!

My Idea was: Create a code that check when the row 8 is blank, and then insert an autosum formula in the rows 9, 10, etc (in the example it will be on column M, but it could vary depending on the amount fou questions...

Thanks for the help!
 
Upvote 0
If it was something more complicated than autosum then I would agree in having a go at this challenge, but considering autosum can be achieved with very little difficulty I would question whether you should devote your resource into solving something else. There may be another member here that disagrees with me and writes you a loop to check how many rows and columns have data in and then inserts the relevant sum formula at the end though...
 
Upvote 0
Thanks for your reply!

I would like to find the solution (in fact I think I will use it in another project...)
 
Upvote 0

Forum statistics

Threads
1,215,422
Messages
6,124,811
Members
449,191
Latest member
rscraig11

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