+ Reply to Thread
Results 1 to 4 of 4

Function help:Public Function

Hybrid View

cooldyood Function help:Public Function 09-11-2006, 04:13 PM
stevebriz try this: Public... 09-11-2006, 04:35 PM
T-J should be Set FoundCell =... 09-11-2006, 07:55 PM
stevebriz You are right TJ..thanks for... 09-11-2006, 07:58 PM
  1. #1
    Registered User
    Join Date
    06-20-2006
    Posts
    15

    Function help:Public Function

    I wrote the following function to copy data across sheets but it doesn't seem to be working. Please tell me if something obvious is wrong. TargetCell is supposed to be in Sheet4 and FoundCell in Sheet2.

    Thx


    Public Function FillCallsData(IYPName As String, TargetCell As Range) As Boolean
    With Worksheets("Sheet2")
    Set FoundCell = Cells.Find(What:=IYPName, After:=Range("A1"), LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False)
    End With

    If FoundCell Is Nothing Then
    MsgBox "No call data for " & IYPName
    TargetCell.Value = 0
    Else
    MsgBox "Address found is " & FoundCell.Address
    Sheets("Sheet2").Activate
    MsgBox FoundCell.Value
    TargetCell.Value = FoundCell.Offset(0, 1).Value
    End If
    End Function

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    try this:

    Public Function FillCallsData(IYPName As String, TargetCell As Range) As Boolean
    With Worksheets("Sheet2")
    Set FoundCell = Cells.Find(What:=IYPName, After:=Range("A1"), LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False)
    End With
    
    If FoundCell Is Nothing Then
    MsgBox "No call data for " & IYPName
    TargetCell.Value = 0
    Else
    MsgBox "Address found is " & FoundCell.Address
    Sheets("Sheet2").Activate
    MsgBox FoundCell.Value
    
     Worksheets("Sheet4").Range(TargetCell.Address).Value = Worksheets("Sheet2").Range(FoundCell.Address).Offset(0, 1).Value
    End If
    End Function

    Sub test()
    FillCallsData "TESTSTRING", Range("A1")
    End Sub
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388
    Set FoundCell = Cells.Find(What:=IYPName, After:=Range("A1"),
    should be Set FoundCell = .Cells.Find(.... and the rest...)

  4. #4
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    You are right TJ..thanks for picking that up.
    Last edited by stevebriz; 09-11-2006 at 08:06 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1