Full Version: Assign A Value To Range Using A Variable
UtterAccess Discussion Forums > Microsoft® Access > Access Automation
Kamulegeya
Greetings members

I have a code that automates Excel from Access DB

I want to use a variable to enter a value in a cell 3 rows after the final row.

I have this variable to get the final row

CODE
finalrow = objApp.Cells(objApp.Rows.Count, 1).End(xlUp).Row

I have a currency variable i want to enter into the cell

CODE
Dim Balance as Currency

Balance =Me.txtBalance


If i try to use
CODE
objSheet.Range("A" & finalrow + 3).Value = "  & Balance & "


The string & Balance & is the one entered in the cell . Not the value of the variable.

But this one works
CODE
objSheet.Range("B14").Value = "Below is Accountability for Petty Cash of 2,000,000 UGX taken on " & Me.Transaction_Date

i.e the value of Me.Transaction_Date is entered into cell B14 plus the string part

Is there way of making it work?

Ronald




Kamulegeya
Hello Members

Problem solved

Changed

CODE
objSheet.Range("A" & finalrow + 3).Value = "  & Balance & "


To

CODE
objSheet.Range("A" & finalrow + 3).Value =  Balance


and it worked

Ronald
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.