Excel 2007 Macro - Range or .Range

Event2020

Board Regular
Joined
Jan 6, 2011
Messages
122
Office Version
  1. 2019
Platform
  1. Windows
Hi

I am using Excel 2007.

When searching the web for answers / tips to writing macros when referencing a range (single cell or several) I have seen both
Code:
.Range("A1").Value = "
" and
Code:
Range("A1").Value = ""
used.

Can someone explain in simple terms what the difference is and when .Range or Range should be used?

Many thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You only use the first example inside a with statement like
Code:
With Sheets("Sheet1")
   .Range("A1") = "Fluff"
   .Range("B1") = "MrExcel"
End With
 
Upvote 0
You only use the first example inside a with statement like
Code:
With Sheets("Sheet1")
   .Range("A1") = "Fluff"
   .Range("B1") = "MrExcel"
End With


Hi Fluff

Thank you for kindly replying - I love learning :)

So which method would you recommend for the below macro?

The macro is looking at a cell, B23, which has a number of option buttons linked to it and if the cell returns specific value, 3, 4 or 5 (ignoring 1 and 2) the macro changes the value of a different cell, B25, to 1.

The macro works fine but in the interest of doing it correctly I wonder if I was using the correct syntax?

Code:
Sub ResetNoCaseSelection()




    If Range("B23").Value = 3 Or Range("B23").Value = 4 Or Range("B23").Value = 5 Then
        Range("B25").Value = 1


    End If
    


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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