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,193
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: 5,980
Joined: 30-June 11



What about

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

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




--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
bakersburg9
post Aug 9 2018, 01:05 PM
Post#3



Posts: 5,193
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    19th August 2018 - 12:49 PM