LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA : Coding Problem

Anyone knows whats wrong with the below codes??

Sub Compare2()
Dim wb As Workbook
Dim wsResult As Worksheet
Dim wsLut As Worksheet
Dim rngCrit1 As Range
Dim rngCrit2 As Range
Dim rngSelected As Integer
Dim rngToCount As Range
Dim rngCritNew As Range
Application.DisplayAlerts = False

On Error Resume Next

Set wb = ActiveWorkbook
If rngCrit1 < "" And rngCrit2 < "" Then
Set rngCrit1 = Application.InputBox("Select data range: "
Type:=8)
Set rngCrit2 = Application.InputBox("Select criteria range: "
Type:=8)
wb.Sheets("Results").Delete
wb.Sheets.Add After:=Sheets("Data")
ActiveSheet.Name = "Results"
Set wsLut = ActiveWorkbook.Sheets("LUT")
Set wsResult = ActiveWorkbook.Sheets("Results")
rngCrit1.Copy Destination:=wsResult.Range("A2")
rngCrit2.Copy Destination:=wsResult.Range("C2")
wsResult.Range("A1") = "Data"
wsResult.Range("A1").Font.Bold = True
wsResult.Range("C1") = "Criterias"
wsResult.Range("C1").Font.Bold = True
wsResult.Range("D1") = "Result of Count"
wsResult.Range("D1").Font.Bold = True
Else
MsgBox "Please select the criteria"
End If

rngSelected = rngCrit1.Count
If rngSelected < 0 Then
With wsResult
Set rngCritNew = .Range("C2", .Range("C2").End(xlDown))
For Each c In rngCritNew
Crit = c.value
critCnt
Application.WorksheetFunction.SumProduct(Len(rngCr it1)
Len(Application.WorksheetFunction.Substitute(rngCr it1, "Crit", "")))
Len("Crit")
c.Offset(0, 1).value = critCnt
Next

ttlmatched
Application.WorksheetFunction.Sum(rngCritNew.Offse t(0, 1))
.Range("C2").End(xlDown).Offset(1, 0) = "No. Matched"
.Range("C2").End(xlDown).Offset(0, 1) = ttlmatched
.Range("C2").End(xlDown).Offset(1, 0).value = "No. NO
matched"
.Range("C2").End(xlDown).Offset(0, 1).value = rngSelected
ttlmatched
End With
MsgBox "Count completed"
End If
Application.DisplayAlerts = True
Exit Sub
End Sub


i believe tat my problem lies he

For Each c In rngCritNew
Crit = c.value
critCnt
Application.WorksheetFunction.SumProduct(Len(rngCr it1)
Len(Application.WorksheetFunction.Substitute(rngCr it1, "Crit", "")))
Len("Crit")
c.Offset(0, 1).value = critCnt
Next

as the codes run smoothly but doesn;t display the result. Anyone ca
help?

--
Message posted from http://www.ExcelForum.com

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VBA coding problem adubbs99 Excel Discussion (Misc queries) 2 April 6th 09 06:28 PM
Help with my coding problem? Dan the Man[_2_] Excel Worksheet Functions 3 September 11th 07 12:02 AM
First attempt at VBA coding problem Rick in NS New Users to Excel 9 January 12th 06 05:11 PM
Excel Coding Problem Fraggs[_14_] Excel Programming 3 April 20th 04 01:50 PM
Coding problem: Runtime 1004 Phil Hageman Excel Programming 0 July 24th 03 05:29 PM


All times are GMT +1. The time now is 09:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"