filling the whole sheet with text or number - vba

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I want to fill the whole worksheet with "hello" or with a number like 1
I wrote the code below. It is only working if
x.Value = "" (clearing the sheet)

but when I type
x.Value = "hello"
or x.Value= 1

I got error message. Any idea how to fix that. Thank
+++++++++++++++

Private Sub CommandButton3_Click()
Dim x As Range
Set x = Worksheets("sheet1").Cells
x.Value = ""
End Sub
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
What does the message say?
Not enough resources?
 
Upvote 0
Of course the next question is, if you could, what are you going to do with 16,777,216 or 14,034,141,184 times hello
 
Upvote 0
no reason. Just to practice different things. Thank you.
 
Upvote 0
In the Immediate Window enter:

msgbox rows.Count*columns.Countlarge

and press Enter to see how many cells you are trying to fill with a value. That causes overflow.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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