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: 69
Default range values counted problem

I am using the following code to assess the number of occurrences of various
values in a selected range in one sheet and place the results in a single
row on another sheet,

The first part select the source range which is fine but when the code gets
to line €“
Set tempRng = Range("Sheet2!1:1").Cells(1, i)

I get a runtime error 1004 message application €“defined error

Can you help resolve this please



Sub GetCells()
Dim res As Variant, rng1 As Range
Dim lastrow As Long, rng As Range
Dim r As Integer
Dim W As Integer
Dim tempRng As Range
Dim i As Integer: i = 1


W = InputBox("Which week do you want to summarise?", "Week Summary", "?")

res = Application.Match(W, Columns(2), 0)
lastrow = res

Do While Cells(lastrow, 2) = W
lastrow = lastrow + 1
Loop

Set rng = Range(Cells(res, 2), Cells(lastrow - 1, 2))
Set rng1 = Intersect(Columns(13), rng.EntireRow)

rng1.Select

With rng1(lastrow, 1)


For Each rng In rng1.SpecialCells(xlCellTypeConstants)
If Not IsNumeric(Evaluate("MATCH(" & rng.Address & ", Sheet2!1:1, 0)")) _
Then
Set tempRng = Range("Sheet2!1:1").Cells(1, i)
tempRng.Value2 = rng.Value2
tempRng.Offset(1, 0).Value2 = Evaluate("COUNTIF(a:a, " & rng.Address _
& ")")
i = i + 1
End If
Next
End With

 
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
Need data counted when changes are made Tmeck Excel Discussion (Misc queries) 0 March 18th 10 07:53 PM
SUMPRODUCT or SUMIF if any values in a range equal any values in another range PCLIVE Excel Worksheet Functions 3 July 15th 09 07:43 PM
Problem with getting numbers in some range values!? Ivica TypeR Excel Worksheet Functions 2 July 10th 07 01:29 AM
Merging Cells but have each cell counted in the range of merged c. gats13 Excel Worksheet Functions 2 November 9th 04 07:14 PM
Validation by counted chars KHW Excel Programming 0 September 12th 03 07:31 PM


All times are GMT +1. The time now is 02:06 PM.

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"