ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formula to VB Code (https://www.excelbanter.com/excel-programming/368364-formula-vbulletin-code.html)

icetrey[_4_]

Formula to VB Code
 

I have a cell formula -=IF(J61500,500,J61*-1)- that I want to put
into a macro. How would this formula need to be typed in a line of
code.


--
icetrey
------------------------------------------------------------------------
icetrey's Profile: http://www.excelforum.com/member.php...o&userid=20329
View this thread: http://www.excelforum.com/showthread...hreadid=565031


Bob Phillips

Formula to VB Code
 
ACtivecell.Formula = "=IF(J61500,500,J61*-1)"

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"icetrey" wrote in
message ...

I have a cell formula -=IF(J61500,500,J61*-1)- that I want to put
into a macro. How would this formula need to be typed in a line of
code.


--
icetrey
------------------------------------------------------------------------
icetrey's Profile:

http://www.excelforum.com/member.php...o&userid=20329
View this thread: http://www.excelforum.com/showthread...hreadid=565031




NickHK

Formula to VB Code
 
Or do you mean:
With ActiveCell
If Range("J61").Value500 Then
.Value=500
Else
.Value =Range("J61").Value-1
End If
End With

NickHK

"icetrey" wrote in
message ...

I have a cell formula -=IF(J61500,500,J61*-1)- that I want to put
into a macro. How would this formula need to be typed in a line of
code.


--
icetrey
------------------------------------------------------------------------
icetrey's Profile:

http://www.excelforum.com/member.php...o&userid=20329
View this thread: http://www.excelforum.com/showthread...hreadid=565031




icetrey[_5_]

Formula to VB Code
 

Thanks. That worked great.


--
icetrey
------------------------------------------------------------------------
icetrey's Profile: http://www.excelforum.com/member.php...o&userid=20329
View this thread: http://www.excelforum.com/showthread...hreadid=565031



All times are GMT +1. The time now is 04:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com