VBA Help required

Please post any questions regarding the program here.

Moderator: 2020vision

VBA Help required

Postby Kentucky » Sat Dec 11, 2010 2:12 pm

I am looking to automate my excel a liitle more
I have a workbook with 2 sheets Sheet1("Results") and Sheet2("Selections")

When I Select a value in sheet1 it populates cell R1 with that selection and it populates cell F1 with another value

What I would like to do is

When R1 changes in sheet1 I would like it to Lookup the value in Sheet2 it needs to look column C if it finds the value AND the Cell next to it is empty (which would be column D) then I would want the Value of F1 Copying to that Cell

Example

Sheet 1 R1=APPLE
Sheet 1 F1= 2.2

Sheet 2

- Column C Column D

Row 1 PEAR- 2.1

Row 2 PEAR- 2

Row 3 APPLE- 2.2

Row 4 GRAPE- 3

Row 5 PEAR- 2.05

Row 6 APPLE- This cell is blank

I would want D6 to be populated with 2.2

Thanks in Advance
Ken
Kentucky
 
Posts: 22
Joined: Tue Aug 04, 2009 8:01 am

Postby Kentucky » Sun Dec 12, 2010 1:39 pm

Hi Guys I seem to be getting somewhere with this problem
Using the code below It is finding the first instance of my search what I want is the last instance

Dim lookFor As Range
Dim rng As Range
Dim col As Integer
Dim found As Variant
Dim Row As Integer
Set lookFor = Sheets("Results").Range("R1")
Set rng = Sheets("Selections").Columns("C:C")
col = rng.Row


On Error Resume Next
Row = Application.WorksheetFunction.Match(lookFor, rng, 0)
found = Application.VLookup(lookFor.Value, rng, col, 0)
If IsError(found) Then
MsgBox lookFor & " not found"
Else: MsgBox "The look-up value of " & lookFor & " is " & found & " in row " & Row
End If
On Error GoTo 0
End If

Any advice would be great
Kentucky
 
Posts: 22
Joined: Tue Aug 04, 2009 8:01 am


Return to Help

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 47 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.