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

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Assign A Value To Range Using A Variable, Office 2007    
 
   
Kamulegeya
post Apr 26 2012, 03:33 AM
Post #1

UtterAccess Ruler
Posts: 1,334
From: Kampala,Uganda The Pearl of Africa



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




Go to the top of the page
 
+
Kamulegeya
post Apr 26 2012, 04:00 AM
Post #2

UtterAccess Ruler
Posts: 1,334
From: Kampala,Uganda The Pearl of Africa



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
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 09:16 PM