Results 1 to 3 of 3

Type Mismatch Error for writing text in a cell

Threaded View

PleaseHelpMe3 Type Mismatch Error for... 01-28-2016, 05:48 PM
bulina2k Re: Type Mismatch Error for... 01-28-2016, 06:14 PM
AlphaFrog Re: Type Mismatch Error for... 01-28-2016, 06:29 PM
  1. #1
    Registered User
    Join Date
    01-25-2016
    Location
    Pennsylvania
    MS-Off Ver
    2013
    Posts
    5

    Exclamation Type Mismatch Error for writing text in a cell

    I'm writing a code that counts the number of cells with the words "no item placed" in a column. I'm also having the code count the total number of cells in the column. Then to have it calculate the percent of unplaced cells. In the end, the code should write a statement in the second row of each column that says "X unplaced cells, X %". X = count/percent. the code works until the line NumUnplaced.Value = Count + " unplaced items, " + percentUnplaced + "%" where I get a type mismatch error. I think it's because NumUnplaced is a Range and the other two our data values. Any ideas on how to fix this?

    Dim NumUnplaced As Range
    Dim Count As Integer
    Dim NumColumns As Integer
    Dim colRange As Range
    Dim NumRows As Integer
    Dim percentUnplaced As Single
    
    Set colRange = ActiveSheet.UsedRange
    NumColumns = colRange.Columns.Count
    NumRows = colRange.Rows.Count - 1
    
    For i = 2 To NumColumns
    Count = Application.WorksheetFunction.CountIf(Columns(i), "Item Not Placed")
    percentUnplaced = Count / NumRows * 100
    
    Set NumUnplaced = ActiveSheet.Cells(2, i)
    NumUnplaced.Value = Count + " unplaced items, " + percentUnplaced + "%"
    
    Next i
    Last edited by FDibbins; 01-28-2016 at 06:45 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Type mismatch error obtaining value from a cell
    By ssu95bm in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-09-2015, 09:30 AM
  2. [SOLVED] type mismatch error on import of text from .txt file
    By Sayre in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2014, 09:45 AM
  3. type mismatch Error when writing data to excel
    By svibuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-11-2013, 07:07 AM
  4. putting an if condition based on text in a cell - runtime error 13: type mismatch
    By rbs123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2013, 04:02 AM
  5. [SOLVED] "Run-time error '13': type mismatch when running macro to add text to end of text
    By nrjordan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2012, 10:34 PM
  6. Type Mismatch Error when deleting a cell
    By Josiah in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2008, 01:07 PM
  7. [SOLVED] Type Mismatch error - tried .text & .value
    By Nicole Seibert in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2006, 01:45 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