Define Range using VBA

farhad

New Member
Joined
May 18, 2009
Messages
41
Good Day

I have the following which writes to a specific cell. I would like to extend the range for column H
Thanks

HTML:
Sub Meet()
 If ThisWorkbook.Sheets(1).Range("H15:H15").Value = "" Then
            MsgBox "Please Enter a Meeting Number"
            Exit Sub
End If
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Your macro doesn't write to a cell, it displays a message box if the cell in H15 is blank/has an empty string.
Please describe in detail what you want the code to do.
 
Upvote 0
Hi Mark

I would like to code to extend to the entire column which is column H as I entering a row each time.
The current code work on the basis, of when a cell in column H is not filled in a message appears to insert a value. Once the value is inserted in column H the next column I auto-fills another number works fine. The current code points to Cell reference H15. I would like to extend this to H1000.
 
Upvote 0
Try
Code:
Sub CheckValues()
    Dim oneCell as Range
    Dim uiEntry as Variant

    For Each oneCell in Range("H15:H1000")
        If oneCell.Value = vbNullString Then
            uiEntry = Application.InputBox("Enter the value for " & oneCell.Address, type:=2)
            If uiEntry = False Then Exit Sub
            oneCell.Value = uiEntry
        End If
    Next oneCell
End Sub
 
Upvote 0
HI Mike

This works, however I don't want it to prompt to enter cells in Column H.
I want to work on basis of when I enter a new row and if column H is blank then the user must enter a value
 
Upvote 0
HI Mike

This works, however I don't want it to prompt to enter cells in Column H.
I want to work on basis of when I enter a new row and if column H is blank then the user must enter a value

Code:
The current code points to Cell reference H15. I would like to extend this to H1000.
I don't understand the problem. Run the macro and it checks H15:H1000 as requested.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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