UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Syntax For Variable In Formula - VBA, Office 2013    
 
   
bakersburg9
post Aug 9 2018, 11:35 AM
Post#1



Posts: 5,306
Joined: 2-November 04
From: Downey, CA


I have a simple macro that copies the time from the cell above, and adds time in minutes - I currently have it hard-coded to add 3 minutes, but I don't want to write separate subs for each iteration - add 1 minute, add 2 minutes, etc

This works great:
CODE
ActiveCell.FormulaR1C1 = "=R[-1]C+2/1440"


But I can't figure out the syntax to hold the # of minutes I want to add in a variable, determine by my input:

CODE
  Dim addNumMinutes As Integer
  
  addNumMinutes = InputBox("Enter # minutes to add")

  ActiveCell.FormulaR1C1 = "=R[-1]C+(addNumminutes)/1440"



Go to the top of the page
 
DanielPineault
post Aug 9 2018, 12:46 PM
Post#2


UtterAccess VIP
Posts: 6,272
Joined: 30-June 11



What about

CODE
  Dim addNumMinutes As Integer
  
  addNumMinutes = InputBox("Enter # minutes to add")

  ActiveCell.FormulaR1C1 = "=R[-1]C" & addNumminutes & "/1440"



Go to the top of the page
 
bakersburg9
post Aug 9 2018, 01:05 PM
Post#3



Posts: 5,306
Joined: 2-November 04
From: Downey, CA


Awesome ! I added the + sign, and it works great ! Thanks! cool.gif
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    10th December 2018 - 11:44 PM