Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default referencing cell via another cell

I'm currently working on referencing a cell in anther sheet which
contins the value I need for comparison.

In other words, Cell A1 on Sheet 1 is equal to Sheet 2, Cell A15. In
my VBA code, I am needing to refer to Cell A1 of Sheet 1 to find the
value of the cell to which it refers. Is this possible?


Thanks
Louis

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default referencing cell via another cell

If Sheet1 cell A1 contains:

=Sheet2!A15

then in VBA

Sub qwerty()
x = Sheets("Sheet1").Range("A1").Value
MsgBox (x)
End Sub

will display the value in Sheet1 cell A1 (which is also the value in Sheet2
cell A15)
--
Gary''s Student - gsnu200728


"ll" wrote:

I'm currently working on referencing a cell in anther sheet which
contins the value I need for comparison.

In other words, Cell A1 on Sheet 1 is equal to Sheet 2, Cell A15. In
my VBA code, I am needing to refer to Cell A1 of Sheet 1 to find the
value of the cell to which it refers. Is this possible?


Thanks
Louis


  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default referencing cell via another cell

Worksheets("Sheet1").Range("A1").Value


"ll" wrote:

I'm currently working on referencing a cell in anther sheet which
contins the value I need for comparison.

In other words, Cell A1 on Sheet 1 is equal to Sheet 2, Cell A15. In
my VBA code, I am needing to refer to Cell A1 of Sheet 1 to find the
value of the cell to which it refers. Is this possible?


Thanks
Louis


  #4   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default referencing cell via another cell

On Jun 11, 2:31 pm, JMB wrote:
Worksheets("Sheet1").Range("A1").Value

"ll" wrote:
I'm currently working on referencing a cell in anther sheet which
contins the value I need for comparison.


In other words, Cell A1 on Sheet 1 is equal to Sheet 2, Cell A15. In
my VBA code, I am needing to refer to Cell A1 of Sheet 1 to find the
value of the cell to which it refers. Is this possible?


Thanks
Louis



Thanks for your help. Here is what I have so far. This is code in a
UserForm and I am wanting it to look at values on the active worksheet
and compare them with a textbox value (as in the code). The value is
not getting put into the cell in the timesheet, and my test msgbox
comes back blank as well. Thanks for any help you can provide. -
Louis
-----------------------------------------------------------

Private Sub CmdEnter_Click()

Dim a As Integer
Dim b As Integer
Dim testFromCell As String

For a = 9 To 300

If Worksheets("Hourly Timesheets").Cells(a, 1).Value = TextBox2.Value
Then
Worksheets("Hourly Timesheets").Cells(a, b).Select
Worksheets("Hourly Timesheets").Cells(a, b).Value = TextBox1.Value
testFromCell = worksheets("Hourly Timesheets").Cells(a, b).Value

End If
Next a

Unload Me
MsgBox testFromCell


End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default referencing cell via another cell

What is b and where is it set??
--
Gary''s Student - gsnu200728


  #6   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default referencing cell via another cell

On Jun 11, 7:09 pm, Gary''s Student
wrote:
What is b and where is it set??
--
Gary''s Student - gsnu200728



Oops - here's the missing code - b is set to the ListIndex of the
combo box:

b = Me.CboLeaveType2.ListIndex

  #7   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default referencing cell via another cell

On Jun 12, 8:18 am, ll wrote:
On Jun 11, 7:09 pm, Gary''s Student

wrote:
What is b and where is it set??
--
Gary''s Student - gsnu200728


Oops - here's the missing code - b is set to the ListIndex of the
combo box:

b = Me.CboLeaveType2.ListIndex




The odd thing is that I can have text (i.e. "car 4") on sheet2 and
have a cell in sheet1 reference it, but when I try doing a date from
sheet2 (or sheet1) and comparing it to the date in my textbox, the
code runs without error but produces no result.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing Cell Next To Today's Date Cell Docktondad Excel Discussion (Misc queries) 5 May 16th 07 10:25 PM
Obtain Cell Formatting in Cell Referencing? Al Franz Excel Programming 1 April 22nd 07 10:51 PM
Referencing a cell based on the value in another cell septillion Excel Discussion (Misc queries) 3 June 30th 06 03:03 AM
Cell Referencing Alex Excel Programming 1 October 19th 04 06:25 PM
Cell Referencing Karen Howard Excel Programming 0 November 17th 03 09:02 PM


All times are GMT +1. The time now is 01:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"