.Text or .Value

abenitez77

Board Regular
Joined
Dec 30, 2004
Messages
133
I have a macro that runs and extracts data from the cells. I noticed that sometimes I have to use .Text and other times .Value. I started out with .Value but I had some problems with data that was being read so I had to use .Text. Is there a rule or best practice for using these 2? I am inserting the results into a SQL Server Table.

Code:
iSheetA.Offset(2, 6).Value
iSheetA.Offset(2, 6).Text
Thanks,
Alex
 
Last edited:

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,953
Office Version
365, 2010
Platform
Windows
I use .Text if I want to return the value as it is displayed in the cell.
To illustrate this, put the value 25 in cell A1, and format it as currency and run this macro:

Code:
Sub test()
MsgBox Range("A1").Value
MsgBox Range("A1").Text
End Sub

.Value would return 25
.Text will return $ 25.00

I also use .Text if it what you are feeding this value into inherently requires a string.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,191
Office Version
365, 2010
Platform
Windows, Mobile
That means normally that your columns aren't wide enough.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,089
Messages
5,509,177
Members
408,712
Latest member
Eve05

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top