referencing to a cell

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
2,104
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi all

when using something like this

msgbox(cells(1,1))

can that only work on the active sheet??

lets say on sheet1 in a1 = have "hello"
but im on sheet 2 when i run the code.
can i have it display the word hello with msgbox(cells(1,1))

i know i can use range(blar balr), i have other reasons for this ask?

mainly i want to loop 6 columns and 300 rows

thanks

dave
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
NO PROBLEM

I figured it out

just use WITH

With Sheets("day")
MsgBox (.Cells(5, 5))
End With
 
Upvote 0
NO PROBLEM

I figured it out

just use WITH

With Sheets("day")
MsgBox (.Cells(5, 5))
End With
You do not actually need the With statement unless you are going to have more rows of data referencing the "day" sheet. If this is the only code line referencing the "day" sheet, then you could do this instead...

MsgBox Sheets("day").Cells(5, 5)
 
Upvote 0
Morning Rick

Thats great, thankyou very much, i will amennd code.

spot on

Dave
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,432
Members
448,961
Latest member
nzskater

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