Raju Kumar Singh

New Member
Joined
Jul 12, 2017
Messages
15
Hi all,

I am bit new to VBA world. I am having one doubt. Is it possible to edit or manipulate a cell data if it consist in a range that is defined as object variable? What I am thinking is if we have a range of cell defined as object variable then we can make changes to that full range of cell not to a particular cell. Please clarify.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Provide details of exactly what you want to do.
 
Upvote 0
If I understood your question correctly, the following code should give you the answer you are looking for:

Code:
Sub test()
Dim myRange As Range
Set myRange = Worksheets(1).Range("A2:C5")
myRange.Cells(2, 3).Value = "Hello"
myRange.Range("B3").Value = "Goodbye"
End Sub

Regards,

CJ
 
Upvote 0
I am having a range of cell from A1 to D50, in that few of the cells are empty. I want to find out those empty cells and fill in 1>color or 2>any user defined character. These option 1 or 2 should be selected by user. Hoping, this clarify my question.
 
Upvote 0
Possibly (if your cells are truly empty/blank and not for example "" as a result of formula)...

Code:
Sub test1()
    Dim x As String
    If MsgBox("Do you want to insert color?", vbYesNo + vbQuestion) = vbYes Then
        Range("a1:d50").SpecialCells(4).Interior.ColorIndex = 6
        Exit Sub
    Else
        x = InputBox("Please enter a value")
        Range("a1:d50").SpecialCells(4).Value = x
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,891
Messages
6,122,105
Members
449,066
Latest member
Andyg666

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