Why won't my cell range populate with any value or allow me to select it in one particular workbook?

ez08mba

Board Regular
Joined
Nov 1, 2011
Messages
225
Office Version
  1. 2016
Platform
  1. Windows
Problem: I'm writing a function and cannot get any cell range to populate with a value, however, I can in other workbooks. I'm also not receiving any type of error like "#VALUE" or others. It simply doesn't populate. All I can figure is the Workbook or maybe its options are causing the issue but I'm not sure why, or how to resolve it. I'm only experiencing this issue with trying to populate the Cell (i.e., Range) but I'm not having any other issues that I'm aware with the cell references... meaning I can retrieve a value from the cell.

What I've tried: I've tried all the basic types of populating the cell range:
  • Range("A1").Value = "Test"
  • Sheets(1).Range("A1").Value = "Test"
  • Cells(1,1).Value = "Test"
  • Worksheets(1).Range("A1").Value = "Test"
  • ... as well with .Select
All other VBA code seems to work fine (e.g., For loops, With statements, MsgBoxs, setting and referencing objects and ranges, etc.).

The workbook was created with Excel 2016 as well as the other workbooks that this VBA code does work
Windows 10 Pro

Thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I think I found my answer here: Cannot VBA write data to cells in Excel 2007/2010 within a function

"A user-defined function called by a formula in a worksheet cell cannot change the environment of Microsoft Excel. This means that such a function cannot do any of the following:

  • Insert, delete, or format cells on the spreadsheet.
  • Change another cell's value. [My highlighting]
  • Move, rename, delete, or add sheets to a workbook.
  • Change any of the environment options, such as calculation mode or screen views.
  • Add names to a workbook.
  • Set properties or execute most methods."
 
Upvote 0
Is the sheet protected?
Hi,
No, it's not protected. I just posted what I think is the answer. Apparently I cannot do this within a UDF (user-defined function), which must be true because outside of the function and within a Sub procedure I could.
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,882
Members
449,097
Latest member
dbomb1414

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