Autofill Formula in next line

antivitamin007

New Member
Joined
Mar 28, 2019
Messages
4
Hi ive been working on a VBA project (Note: im still a novice and google everything I need to know) Ive developed a userform to capture some employee details and in the process to calculate the days to expiration of set dates against every new employee...

The sting that I use are as follow:

Cells(erow, 19).Formula = "=$J$2-today()"
Cells(erow, 20).Formula = "=$L$2-today()"
Cells(erow, 21).Formula = "=$M$2-today()"
Cells(erow, 22).Formula = "=$N$2-today()"
Cells(erow, 23).Formula = "=$O$2-today()"
Cells(erow, 24).Formula = "=$P$2-today()"
Cells(erow, 25).Formula = "=$Q$2-today()"
Cells(erow, 26).Formula = "=$R$2-today()"

When using the above command, I fail to have the formula "auto fill" to the next line by making the cell line reference absolute.

can you perhaps assist me in rectifying the matter please?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Did you purposely skip $K$2 or is it a typo in your post...
 
Upvote 0
Unfortunately no, honestly speaking I'm not even sure how to exactly use the R1C1 format, and don't know how I would effect the coding.

Lol, take note that I am an extreme novice with coding and basically code by using threads I followed and by teaching myself in that manner. I'm literate enough to help myself, but that's the about it.
 
Upvote 0
Yes that was deliberate as I added an additional column in the worksheet which I then had to adjust m userform and the coding according to.
 
Upvote 0
Is this what you are looking for...

Code:
Cells(erow, 19).Formula = "=J$2-today()"
Cells(erow, 20).Formula = "=L$2-today()"
Range(Cells(erow, 20), Cells(erow, 20)).AutoFill Range(Cells(erow, 20), Cells(erow, 26))
 
Last edited:
Upvote 0
Is this what you are looking for...

Code:
Cells(erow, 19).Formula = "=J$2-today()"
Cells(erow, 20).Formula = "=L$2-today()"
Range(Cells(erow, 20), Cells(erow, 20)).AutoFill Range(Cells(erow, 20), Cells(erow, 26))

Hi igold

Unfortunately I does not seem to solve the problem as it still makes reference to the cell specified within the code: E.g ="=J$2-today()" ect.

is there not of code that I can use to rather make reference for autofill from the previous /above cell without specifying the cell and while maintaining the formula to e used by the cell? (Hope tat makes sense)
 
Upvote 0
Sorry, I am not sure what you are looking for. Perhaps you could better describe using the cells and formulas you would like to see. The code I provided seems to fill the requirement in your OP.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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