+ Reply to Thread
Results 1 to 3 of 3

function call on left-hand side of assignment must return Variant or Object

  1. #1
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    function call on left-hand side of assignment must return Variant or Object

    Hi Team,

    I have a below function

    Public Function RowCountMatches(fileName As String) As String

    Dim TDSheet As Worksheet
    Dim DB2Sheet As Worksheet

    Dim lRow1, lRow2 As Long
    Dim lCol As Long
    Dim TdsheetCount, db2sheetCount As Integer
    'Dim fileName1 As String

    'Set fileName1 = fileName

    Set TDSheet = ActiveWorkbook.Sheets(2)
    Set DB2Sheet = ActiveWorkbook.Sheets(3)

    lRow1 = TDSheet.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
    lCol1 = TDSheet.Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

    lRow2 = DB2Sheet.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
    lCol2 = DB2Sheet.Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

    If lRow1 <> lRow2 Then
    ' write log for missing rows in text file
    Call compareAndWriteMissingRows(fileName)
    End If

    End Function

    In compareAndWriteMissingRows function

    Public Sub compareAndWriteMissingRows(fileName As String)

    Dim rcell As Range
    Dim x, y, z As Long
    Dim strLastCol As String
    Dim lngLastCol As Long
    Dim CellData As String
    Dim i, j As Integer
    Dim bool As Boolean
    Dim Status As String
    'Dim RowCountMatches As String

    Status = "FALSE"

    If x > y Then ' TD Sheet has more rows than DB2 Sheet
    With Sheets("Norm Result")
    lngLastCol = .Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column
    strLastCol = Split(.Cells(1, lngLastCol).Address, "$")(1)

    For Each rcell In .Range(.Cells(2, 1), .Cells(x, z))

    For i = 1 To rcell.Rows.Count

    For j = 1 To rcell.Columns.Count

    If rcell.Value <> Sheets("Teradata Result").Cells(rcell.row, rcell.Column) Then
    'If j = rcell.Columns.Count Then
    'Sheets("Compared Result").Cells(rcell.row, rcell.Column) = "FALSE"
    'Sheets("Compared Result").Cells(rcell.row, rcell.Column).Interior.ColorIndex = 3
    bool = False
    Open "C:\EEMS_SIT\Macro Test\Anand Test\LOGFILE.txt" For Output As #1
    Write #1, "Run Date is : " & Date
    CellData = ""
    CellData = "(" & rcell.row & "," & rcell.Column & ")" & "rows are missing in DB2" & fileName
    Write #1, CellData,
    Close #1
    'Write #1, Sheets("TeraData Result").Cells(rcell.row, rcell.Column)
    'Else
    'Sheets("Compared Result").Cells(rcell.row, rcell.Column) = "TRUE"
    End If

    j = j + 1

    Next j

    Next i

    Next rcell

    End With
    End If

    If (bool = False) Then
    RowCountMatches = Status
    End If

    i am getting above error as function call on left-hand side of assignment vba in below code

    If (bool = False) Then
    RowCountMatches = Status
    End If

    Please help me on this

    Anand R

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,624

    Re: function call on left-hand side of assignment must return Variant or Object

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    12-21-2014
    Location
    chennai
    MS-Off Ver
    2010
    Posts
    37

    Re: function call on left-hand side of assignment must return Variant or Object

    hi

    Sorry for the inconvenience that caused. Anyway my issue got resolved.

    Regards,
    Anand R

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 12-21-2013, 09:54 AM
  2. [SOLVED] Function Call on left-hand side... error
    By SeanDamnit in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-15-2012, 07:08 AM
  3. Call function must return variant or object
    By BCITgirl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2010, 03:23 AM
  4. [SOLVED] y-axis moves from the left hand side to the right hand side
    By JP in forum Excel General
    Replies: 1
    Last Post: 03-13-2005, 01:06 PM
  5. [SOLVED] y-axis moves from the left hand side to the right hand side!
    By JP in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-10-2005, 09:06 PM

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