Formulas

Joined
Mar 18, 2011
Messages
45
Hello everybody!

I would like to right a formula like that in vba Cells(ult_lin, ult_col2 + 1) = "=" & ult_col & "" & ult_lin & "-" & ult_col1 & "" & ult_lin & "" but it have to appear like =C10-D10 cell F10, got it?

How can I do it??


Thanks and have a good weekend!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Code:
Cells(ult_lin, ult_col2 + 1).Formula = "=" & ult_col & "" & ult_lin & "-" & ult_col1 & "" & ult_lin & ""
 
Upvote 0
yeah... but it's not working =(...

it's giving me something like =310-410. 3 because of the column C and 10 because the row, join C10 it will be 310.

is there another way to read the variables as column and row like example F10???
 
Upvote 0
Try

Code:
Cells(ult_lin, ult_col2 + 1).Formula = "=" & Cells(ult_lin, ult_col).Address & "-" & Cells(ult_lin, ult_col1).Address
 
Upvote 0
yeah that works, but it lock the rows and columns... and if my next command is:

Range(Cells(ult_lin, ult_col2 + 1), Cells(ult_lin, ult_col2 + 4)).Select

Selection.AutoFill Destination:=Range(Cells(ult_lin, ult_col2 + 1), Cells(2, ult_col2 + 4)), Type:=xlFillDefault

it will give me the same row and column in all range that I fill dragging this formula, go it!?

I know that i'm being so demanding... but could you guys help me out, please??? =]

thanks a lot!
 
Upvote 0
Try

Code:
Cells(ult_lin, ult_col2 + 1).Formula = "=" & Cells(ult_lin, ult_col).Address(False, False) & "-" & Cells(ult_lin, ult_col1).Address(False, False)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,712
Members
452,939
Latest member
WCrawford

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