ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   referencing cell via another cell (https://www.excelbanter.com/excel-programming/391107-referencing-cell-via-another-cell.html)

ll

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


Gary''s Student

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



JMB

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



ll

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


Gary''s Student

referencing cell via another cell
 
What is b and where is it set??
--
Gary''s Student - gsnu200728

ll

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


ll

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.


JMB

referencing cell via another cell
 
The information in the textbox is, I believe, being treated as text which is
not equal to a numeric date value.

try:
CDate(Me.TextBox1.Value) to convert the text date to numeric value.


"ll" wrote:

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.



ll

referencing cell via another cell
 
On Jun 12, 11:02 am, JMB wrote:
The information in the textbox is, I believe, being treated as text which is
not equal to a numeric date value.

try:
CDate(Me.TextBox1.Value) to convert the text date to numeric value.

"ll" wrote:
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.




Many thanks - that did the trick!



All times are GMT +1. The time now is 09:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com