Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8145035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:32:22+00:00 2026-06-06T13:32:22+00:00

This works Lastrow = 8, but not 9 (Type mismatch) If i remove If

  • 0

This works Lastrow = 8, but not 9 (Type mismatch)

If i remove If Not (myarray = Empty) Then it does not work for 8

What is the easiest way to solve this?

Public Function GetRowToWriteOn(ByVal SheetName As String, ByVal idnr As Integer) As Integer
    LastRow = (Sheets(SheetName).UsedRange.Rows.Count) + 1
    MsgBox (LastRow)
    myarray = Sheets(SheetName).Range("d8:d" & LastRow).Value
    If Not (myarray = Empty) Then
        For row = 1 To UBound(myarray, 1)
            If (myarray(row, 1) = idnr) Then
                GetRowToWriteOn = row
                Exit Function
            End If
        Next
    End If
    GetRowToWriteOn = LastRow
    Exit Function
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:32:23+00:00Added an answer on June 6, 2026 at 1:32 pm

    MyArray is taking 2 different types, depending on the range given.
    If you are looking at 1 cell, then it is a single variant (which can be tested if it is Empty)
    If you are looking at 2 or more cells, then it becomes an array of variant, so you would have to test each cell.

    myarray = Sheets(SheetName).Range("d8:d8").Value – myarray gets the value in d8
    myarray = Sheets(SheetName).Range("d8:d9").Value – myarray(1,1) gets the value in d8, and myarray(2,1) gets the value in d9

    to test, use:

    if vartype(myarray)=vbArray then
        ' run through the array
    else
        ' do single value stuff
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works: require 'csv' file = CSV.open(filename) puts file.shift This does not: require 'csv'
I have tried many things, but I'm still not getting this to work. Here's
This works but for some reason the comma is missing. data gets inserted as
This works when I used a rectangle as the food but now I'm trying
This works, but when I hover the first time, nothing loads. When I mouse
I have a gridview and if I remove a row in this way: foreach(Label
I'm using this code to delete a row in a table, but it's not
I wonder why this works strange. I understand that the difference is grouping, but
This works. $(document).ready(function(){ $(.items article).click(function(){ window.location=$(this).find(a).attr(href); return false; }); }); However , when the
This works: <cfdirectory action=list name=qry directory=C:\inetpub\wwwroot\Atlas\ > </cfdirectory> <cfdump var=#qry#> So I know that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.