ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   referencing another worksheet in a formula (https://www.excelbanter.com/excel-programming/375303-referencing-another-worksheet-formula.html)

Josie[_2_]

referencing another worksheet in a formula
 
Afternoon,

As titled really, I'm sure it'll be easy for you clever lot. The other sheet
is called Refnumbers. Here's the code so far:

Dim i As Integer
Dim j As Integer
i = 6
j = 1

Do While i < x
Cells(i, j).Select
Select Case Cells(i, j).Value
Case 100, 101, 102, 103, 104, 105, 106, 107, 110, 141, 160, 171, 191
Cells(i, j + 2).Select
Dim answer As String
**answer = Cells(i, j + 1).Value * Refnumbers!Cells(5, 2).Value**
ActiveCell.Formula = answer
i = i + 1
etc

The debugger sticks on the line with ** at each end.

Charles Chickering

referencing another worksheet in a formula
 
answer = Cells(i, j + 1).Value * Worksheets("Refnumbers").Cells(5, 2).Value
--
Charles Chickering

"A good example is twice the value of good advice."


"Josie" wrote:

Afternoon,

As titled really, I'm sure it'll be easy for you clever lot. The other sheet
is called Refnumbers. Here's the code so far:

Dim i As Integer
Dim j As Integer
i = 6
j = 1

Do While i < x
Cells(i, j).Select
Select Case Cells(i, j).Value
Case 100, 101, 102, 103, 104, 105, 106, 107, 110, 141, 160, 171, 191
Cells(i, j + 2).Select
Dim answer As String
**answer = Cells(i, j + 1).Value * Refnumbers!Cells(5, 2).Value**
ActiveCell.Formula = answer
i = i + 1
etc

The debugger sticks on the line with ** at each end.


Josie[_2_]

referencing another worksheet in a formula
 
You star. This has been driving me up the wall.

"Charles Chickering" wrote:

answer = Cells(i, j + 1).Value * Worksheets("Refnumbers").Cells(5, 2).Value
--
Charles Chickering

"A good example is twice the value of good advice."


"Josie" wrote:

Afternoon,

As titled really, I'm sure it'll be easy for you clever lot. The other sheet
is called Refnumbers. Here's the code so far:

Dim i As Integer
Dim j As Integer
i = 6
j = 1

Do While i < x
Cells(i, j).Select
Select Case Cells(i, j).Value
Case 100, 101, 102, 103, 104, 105, 106, 107, 110, 141, 160, 171, 191
Cells(i, j + 2).Select
Dim answer As String
**answer = Cells(i, j + 1).Value * Refnumbers!Cells(5, 2).Value**
ActiveCell.Formula = answer
i = i + 1
etc

The debugger sticks on the line with ** at each end.



All times are GMT +1. The time now is 04:47 PM.

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