Is it possible to change a value of another cell with a UDF?

cvraman

New Member
Joined
Dec 26, 2015
Messages
12
Hi guys,
Im kind of beginner in vba.
Below is a simple udf.
If two criteria match it will return with the value from the WorksheetFunction.Index(Sheets("TP_IP_range").Range("C:C"), add, 0).

I would like to change the value of Worksheets("TP_IP_range").Range("B" & add"). Is it possible somehow??


Function tp_ip()


Dim add As Integer
Dim start As Integer
Dim rng As Range
Dim ip As String


start = 0
Set rng = Workbooks("Ran_ports_master.xlsm").Worksheets("TP_IP_range").Range("E:E")


Do
add = WorksheetFunction.Match("-", rng, 0)
add = add + start
ip = WorksheetFunction.Index(Sheets("TP_IP_range").Range("C:C"), add, 0)

If WorksheetFunction.Index(Sheets("TP_IP_range").Range("A:A"), add, 0) <> "" Then
start = add
add = add + 1
Set rng = Worksheets("TP_IP_range").Range("E" & add & ":E17000")
Else
tp_ip = ip
Exit Do
End If


Loop
End Function


thanks in advance
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Worksheets("TP_IP_range").Range("B" & add").Value=

Then just add what ever you want the cell to be populated with after the equal sign. Could be a value, variable, formula, etc.
 
Upvote 0
Hi dUBBINS,

Thank you for your help but unfortnately it is not working.
Worksheets("TP_IP_range").Range("B" & add).Value= "ok"

I think it is not possible to solve with "basic" solutions. How it looks it is not possible to change the environment in excel with the use of a function: http://support.microsoft.com/kb/170787
I was just hoping that there is a loophole for it :D

thanks
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

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