How to update the value in an OFFSET cell

ififthelement

New Member
Joined
Sep 11, 2014
Messages
48
Hi,

I have Sheet1 which has following data:
[TABLE="class: grid, width: 50, align: left"]
<tbody>[TR]
[TD]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]a, b, c, d[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD]=FindCount(A1)[/TD]
[/TR]
</tbody>[/TABLE]





In the VBA-Project, I have a Module with following code :

Public Function FindItemCount(LinkedItems As Range)
On Error Resume Next
Dim tmpItems, curAddr
Dim indx As Integer
Dim LocOffset

tmpItems = Split(LinkedItems.Value, ", ") ' Delimiter is COMMA & SPACE
Set LocOffset = LinkedItems.Offset(0, 1) ' to set a value in B1

indx = UBound(tmpItems)

LocOffset.Value = indx ' Generates Application-defined or Object-defined Error - Why ?:confused:
' Do other necessary stuff


End Function


The intent is only to find how many items are there and update the OffSet COLUMN (:warning: not happening) with a value of the count.
Then read read each item and do necessary work.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Perhaps this:-
Code:
Function Fcount(R As Range) As Integer
Fcount = IIf(UBound(Split(R, ",")) = 0, 1, UBound(Split(R, ",")))
End Function
 
Upvote 0
:) clever answer, but the issue is in the line LocOffset.Value = indx ' Generates Application-defined or Object-defined Error - Why ?
However, If i replace the code above with FindItemCount= indx, which works well and puts the indx in the cell C1 - where the function was called. But I want to use the offset and put the value in another cell.

If OffSet only to READ value. Can it not update the Cell it refers to ?
:confused:
 
Upvote 0
iteration loop if you look at a cell from one address and try to update the looked at cell

it is like saying =if(A1=4, A1=5, B1=6)
 
Upvote 0
Hi,

I may not have the adjacent column available always, so I wanted to use OffSet to specify where i want the update to happen.

1) Is OffSet only to READ value and not update ?
2) Does OffSet work only when I do .SELECT & using ActiveCell ? because there are a couple of example where they typically do .SELECT & use ActiveCell

Can someone pick this query ? I still dont have a reply to the actual query :confused:
 
Upvote 0
=offset($A$1,4,5) will return the value in E4 to A1

E4 will not be changed

instead of 4 and 5 you could build 2 match functions into the offset formula
 
Upvote 0
if you want to update any cell dependent on certain criteria,you need to use vba

for example if your data is 4,5,6 and that means you want to put 6 into cell E4

cells(4,5)=6

if A1 = 4 and B1 =5 and C1=6

cells(cells(1,1),cells(1,2))=cells(1,3)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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