LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bon Bon is offline
external usenet poster
 
Posts: 23
Default Need help on generating non-duplicated result

Hello All

Please give me some advices on generating non-duplicated result. My
idea and codes are as follow.

I got two worksheets - Subjects worksheet and Result worksheet. The
subject worksheet contains subjects name, years and page numbers. It
looks like

1990 1991 1992 1993 1994 Total Page
Eng 1 7 4 6 8 5
Maths 2 3 4 5 6
Chem 3 9 7 6 4
Phy 3 5 8 9 10 10

When the user click the page number, cell will be highlight and total
page of that subject will be calculated and displayed in total page
column. For example, teacher A clicks Cells(2,2), Cells(2,4) and
Cells(5,5), those will be highlighed and the total page number for Eng
and Phy will be calculated and shown on total page column respectively
(i.e. 5 and 10).

On the Result worksheet, it will show highlighed subject, year and page
number only. For the above example, it will show:
1990 1992 1994
Eng 1 4
Phy 10

But, my result is look like:
1990 1992 1994
Eng 1
Eng 4
Phy 10

Here is my code for Result worksheet:

Private Sub Worksheet_Activate()
Dim ALWorksheet As Worksheet
Dim intPasteYear As Integer
Dim intPasteSubj As Integer
Dim intPageNum As Integer

Dim bYearFlag As Boolean
Dim bSubjFlag As Boolean

Set ALWorksheet = Worksheets("Subjects")

intPasteYear = 2
intPasteSubj = 2

intPageNum = 2

For intCol = 2 To 12
bYearFlag = False

For intRow = 2 To 12

If ALWorksheet.Cells(intRow, intCol).Interior.ColorIndex =
6 Then
If bYearFlag = False Then
With Cells(1, intPasteYear)
.Value = ALWorksheet.Cells(1, intCol)
.Font.Bold = True
intPasteYear = intPasteYear + 1
bYearFlag = True
End With
End If

Cells(intPasteSubj, 1) = ALWorksheet.Cells(intRow, 1)
intPasteSubj = intPasteSubj + 1

Cells(intPageNum, intPasteYear - 1) =
ALWorksheet.Cells(intRow, intCol)
intPageNum = intPageNum + 1
End If
Next
Next
End Sub

Please give me some suggestion on solving this problem.

Thank you very much

Bon

 
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
SUM formula generating formula instead of result. klymkibo Excel Worksheet Functions 2 February 23rd 07 07:26 PM
duplicated values baha Excel Discussion (Misc queries) 2 December 10th 06 11:11 PM
Duplicated cells Claudiotto Excel Worksheet Functions 1 September 9th 06 06:08 PM
Duplicated rows cj21 Excel Discussion (Misc queries) 1 July 29th 05 01:55 PM
non-duplicated values scrabtree23[_3_] Excel Programming 1 February 8th 05 05:54 PM


All times are GMT +1. The time now is 04:21 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"