PDA

View Full Version : Solved: Assign VBA Variable from Excel Cell



Kindly_Kaela
12-27-2006, 02:14 PM
I want to assign a VBA variable to a number in an excel spreadsheet.

Let's say for example, cell D3 in a spreadsheet. And the VBA variable is named ABC. How do I make ABC = D3?

Thank you!
Kaela
:cloud9:

Erdin? E. Ka
12-27-2006, 02:23 PM
Hi Kaela,

I can try this codes:

Sub Assign_A_VBA_Variable1()
ABC = [D3]
End Sub

Or,

Sub Assign_A_VBA_Variable2()
ABC = Range("D3")
End Sub

Or,


Sub Assign_A_VBA_Variable3()
ABC = Cells(3, 4)
End Sub

Brandtrock
12-27-2006, 03:15 PM
Assuming that the variable is either a variant (will hold any data, but uses more memory) or has been set up as the proper type for the cell contents using Dim,

ABC = Range("D3").value

Kindly_Kaela
12-27-2006, 03:43 PM
Thank you Gentleman!!

:beerchug: