The Excel VBA Value property is how your macro reads text, numbers or dates out of a cell, or writes new content into one. The shortest working pattern is Range("A1").Value = 100 to write and x = Range("A1").Value to read. Nothing extra needs installing: the VBA editor ships with every desktop copy of Excel, so you only need a workbook that can save macros and the Developer tab switched on.
This is the property you will use more than any other in Excel automation, so it is worth learning its small set of rules: what it returns, how it treats blank cells, when it hands back a date instead of a string, and why pointing it at a merged range or a whole column can slow a macro to a crawl.
What You'll Need
- Excel for Windows or Mac (the VBA editor is not available in Excel for the web).
- The Developer tab visible. If it is missing, right-click the ribbon, choose Customize the Ribbon, and tick Developer in the list on the right. Menu labels can differ slightly by version, device and region.
- A macro-enabled workbook saved as
.xlsm, or an.xlsbfile, so your code survives closing and reopening. - Basic familiarity with the VBA editor: press Alt+F11 (Windows) or Option+F11 (Mac) to open it, and use Insert > Module for a blank code sheet.
Step-by-Step
Open the VBA editor and add a module. Press Alt+F11 on Windows or Option+F11 on a Mac. In the editor choose Insert > Module. Everything below goes into that module.
Create a test macro that writes a value. Type:
Sub WriteCell() Range("A1").Value = 100 End SubPlace the cursor inside the Sub and press F5 to run it. Cell A1 now holds the number 100. The property name is optional when writing, because
Range("A1") = 100calls the default property namedValueanyway, but writing it out makes your intent obvious to anyone reading the code later.Read a value back. Add a second macro:
Sub ReadCell() Dim result As Variant result = Range("A1").Value MsgBox result End SubUse
Variantfor the receiving variable.Valuecan return a number, text, a date, an error value orEmpty, and only a Variant can hold all of those without a type mismatch.Point at cells safely. Prefer a qualified reference so the code always hits the workbook and sheet you mean:
ThisWorkbook.Worksheets("Data").Range("B2").Value = "Hello"An unqualified
Rangerefers to whatever sheet is active, which is the most common reason a macro writes to the wrong place after a user clicks another tab.Write a whole block at once. Instead of looping cell by cell, assign a two-dimensional Variant array to a multi-cell range. Excel fills it in one operation:
Dim arr As Variant ReDim arr(1 To 3, 1 To 2) arr(1, 1) = "Name": arr(1, 2) = "Score" arr(2, 1) = "Ana": arr(2, 2) = 91 arr(3, 1) = "Ben": arr(3, 2) = 78 Range("D1").Resize(3, 2).Value = arrIt works in reverse too:
arr = Range("D1:E3").Valuereturns a 1-based two-dimensional array, which is the fastest way to read a table.Convert deliberately. If you need a string, use
CStr(Range("A1").Value); for a number,CDblorCLng; for a date,CDate. This also prevents Excel from guessing when you assign text that looks like a number.Handle blank cells. A blank cell returns
Empty, not zero and not an empty string. Test withIsEmpty(Range("A1").Value). To turn blanks into something readable, useNz-style logic manually:If IsEmpty(v) Then v = "".Save and test again. Save the workbook as
.xlsm, close it, reopen, and run each macro from the Developer tab under Macros. If your security settings block macros, Excel shows a yellow bar; allow content only for files you created or trust.
Common Mistakes
- Mixing up
ValueandValue2. They behave identically for text, but for dates and currencyValuereturns a Date serial andValue2returns the underlying number. Reading a date withValue2and displaying it gives you a strange number like 45678. - Assigning to an object wrongly.
Set Range("A1").Value = 5fails;Setis only for object references. Plain=is correct for values. - Losing number formats. Writing
"01/02/2026"into a cell stores a string, not a date. UseCDateorDateSerial(2026, 2, 1). - Writing to a protected sheet or a locked cell without unprotecting it first. You will get an error 1004 that has nothing to do with
Valueitself. - Reading hundreds of cells in a loop when one array assignment would do it. This is the usual cause of a macro that takes minutes instead of a second.
- Assuming
Range("A1").Valueis text. If the cell contains an error such as#N/A, the property returns an error value, and arithmetic on it raises a type mismatch. Check withIsError.
Tips
- Use
Range("A1").Value2in performance-critical loops and convert to a date only where you display it. - Wrap screen updates off while a macro writes many cells:
Application.ScreenUpdating = Falsebefore,Trueafter, and reset it in an error handler so it is never left off. - For a single cell on the active sheet,
Cells(2, 3).Valuemeans row 2, column 3, which is handy inside loops where row and column numbers are variables. - If the cell holds a formula and you want the displayed result,
Valuegives you that; useFormulaif you need the formula text itself. - When copying values between sheets, assign arrays rather than using copy and paste; it avoids the clipboard entirely and is faster and quieter.
Troubleshooting
If that did not work, work through these in order.
- Confirm the macro actually ran: check the Immediate window (Ctrl+G in the editor) or add a
MsgBoxline as the first statement. - Check which sheet is active if you used an unqualified
Range. Qualify it with the workbook and worksheet. - Read the error number and description. Error 1004 usually means a bad range reference, a protected sheet or a locked cell. Error 13 (type mismatch) usually means you assigned text to a numeric variable or forgot to use Variant.
- Press Debug when the error dialog appears, then hover over the variable to see what it actually holds.
- If nothing happens when you press F5, the cursor may be outside a Sub, or the workbook may be in a state where macros are disabled. Check the ribbon for the security warning bar and enable content for your own file.
- If results look stale, check whether the sheet is set to manual calculation, or whether the cell is merged and you are reading only its top-left corner.
Frequently Asked Questions
What is the difference between Value and Value2?
Value converts dates and currency to their VBA-native forms; Value2 returns the raw underlying number. For text and ordinary numbers they are the same.
Why does my blank cell show as a strange value?
A truly blank cell returns Empty. If you see zero, the cell contains a formula or a number formatted oddly. Test with IsEmpty to confirm.
Can I write to several cells with one line?
Yes. Range("A1:A3").Value = 5 fills all three cells with 5. For mixed content, use an array assigned to a multi-cell range.
Does Value work on cells containing formulas?
It returns the calculated result, not the formula. Use the Formula property if you need the formula text, or HasFormula to check first.
Why does writing a date turn into text?
You wrote a string. Assign a real date with CDate("2026-02-01") or DateSerial(2026,2,1) so Excel stores a date value.
Is Value available in Excel for the web?
No. The VBA editor and macro execution live in the desktop app for Windows and Mac; the web version will show VBA files but will not run the code.