.Text or .Value

abenitez77

Board Regular
Joined
Dec 30, 2004
Messages
149
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:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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.
 
Upvote 0
That means normally that your columns aren't wide enough.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top