Page 2 of 2 FirstFirst 12
Results 41 to 64 of 64

Thread: [SOLVED]Adding values to cells(values from different sheet)

  1. #41

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    Ok ...I've attached a sample on blkview and mapview to illustrate how mine works(here I've done it with the help of a userform). When u first open the page, start VB editor and run the form. Click the button on the top first. The first button is the one which creates the blkview using a pivot table. (if u want to try it out several times, unprotect the sheet and delete contents). The second button below it is the one that transfers data to mapview. If u click n see, nothing happens. But lets say, u hav selected the cells in mapview then u run and click the 2nd button, U will notice that the data transfer to only the first block in mapview(furthermore, the following cells below will be empty).I hope u can visualize and undestand better. hope tyo hear from u soon.
    Attached Files Attached Files

  2. #42
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Hi,
    I can't figure the problems you observed regarding not filled cells or Overflow.
    Regarding
    If u click n see, nothing happens. But lets say, u hav selected the cells in mapview then u run and click the 2nd button, U will notice that the data transfer to only the first block in mapview
    As you told me to do it for:
    My idea(which I do not know how to do) is first to specify a range from mapview to choose from.
    I made a code for trhe instance that the selection was made before.

    However using your new example I did the following:

    Adjusted that all Periods will be filled at one click (2nd Button).
    The Alphanumeric have to be in 3 columns (15,15 and 8 values) for each Period. The Values itself don't have to have any format.
    If a empty cell in blkview is found, "0" is filled into mapview.

    I hope that's it now.
    Last edited by opus; Jul 18th, 2007 at 02:51 AM.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #43

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    THANK YOU SO MUCH FOR UR EFFORT TAKEN THESE DAYS. THANK YOU VERY VERY VERY VERY MUCH.IM REALLY REALLY HAPPY NOW!

  4. #44
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    I guess you owe me one, see next time I come to Singapore!

    What bugs?, yours or mine?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  5. #45

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    YOUR SOLUTION DOES 95% OF WATS REQUIRED BUT WHEN I TRIED THAT FOR SOME OTHER VIEW IT SHOWS 0 ,0, 0 IN BLANK SPACES... I KNOW U WON'T UNDERSTAND WAT IM SAYING TSTA Y I SENT HOW IT LOOKS LIKE.BTW I'VE USED THE SOLUTION TO CHANGE FOR THE DIFFERENT TYPES OF INFO. U CAN C TAT THERE ARE ADDITIONAL INFO IN THE 3 CELLS BUT THEY R NOT SO DIRECT LIKE THE BLK VIEW... LOOK AT THOSE ZEROS WHERE THEY ARE NOT SUPPOSED TO BE..(MEANING WHERE THERE'S NO INDICATION OF ANY BLOCK). AND I NEED ZEROS TO BE DISPLAYED IF WHATEVER VIEW IT IS RETRIVEING FRM IS EMPTY....Y IS IT SO?
    Attached Files Attached Files

  6. #46
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    If you'Re talking about the zeros in the non-colored fields, that'S because the code I send uses 15 doublerows for the first and second block in a Period and 8 for the third.
    I think YOU can adjust that easily yourself! Look at the comments!
    As for the tripple Zero, I didn't do them!!!, I only filled the Cells that are below the values like "B01"!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  7. #47

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    yeah I understand what u mean and think i could change it myself...just asked to c whether it was possible to optomize the code so tat it can be reused for diff types of views tats all.. anywy thanks buddy.

  8. #48

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86

    Adding comments in Excel

    OPus... I've got a new problem here..Not that prev one but similar. I've attached a file u can see.Same thing, in Sheet1, I've got a pivot table listing Periods,TT_iD,and Blks. I want those TT_Ids under a certain blk at a certain period(jus like the one u did) to be display in mapview as Comments. The way it should be shown, I've it in Sheet2, for C13 in period7,B01 at period 1 and B01 at period 0 (samples). I know its quite similar to ur codes but i do not know how to reference cell as wat u did.. Ur standard is quite "high" for me.pls help..Thanks
    Attached Files Attached Files
    Last edited by ITboy; Apr 1st, 2003 at 01:20 AM.

  9. #49
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Hi
    I really think you will into this problem more often, only because you use those "pivot-tables" (what are they, some EXCEL-buildin functions eh?).
    Once again the question, will it be during one action that you fill those "pivot-tables" and then do the rest????
    IF YES, it would be much easier to do it all at same time, since the referencing would be no problem!!!!

    On your question, how to reference in this example:

    Do it similarv to the last one:
    loop thru
    all periods
    for all 3 blocks in a period (8 ,8 or 3 values)
    if the "Alphanumeric value matches to blk
    Get all values of TTId that don't hold "" in the period cell
    (the problem in here is you have to take more than one
    TTId, the ones following with an empty cell in column
    1 are also for this blk)[that the reason for the question
    above]

    I hope you can do that alone!

    If you have problems regarding the exact coding to put comments, just use the build in macro-recorder!!!!

    Use a new thread for new questions, the loading time for this threat get'S bigger and bigger!!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  10. #50

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    ya for ur question..Once again the question, will it be during one action that you fill those "pivot-tables" and then do the rest????
    , it is YES..Just like the prev one..

  11. #51

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    I've tried it but getting application defined object defined error. This is how I changed.

    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim Name As String
    Dim Period As Integer
    Dim BlkName As String
    Dim MaxNumber As Integer
    MaxNumber = 100
    Sheets("mapview").Activate
    'for Periods 0 to 8
    For k = 0 To 8
    'First block of alphanumerics (15 Values)
    For i = 1 To 15
    For j = 3 To MaxNumber
    If Sheets("Sheet2").Cells(j, 1).Value = ActiveSheet.Cells(1 + 2 * i, 12 * k + 2).Value Then
    If Not Sheets("Sheet2").Cells(j, Period + 2).Value = Empty Then
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 1).AddComment
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 1).Comment.Visible = False
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 1).Comment.Text Text:=Sheets("Sheet2").Cells(j, k + 2).Value 'Text:="SIRAJ:" & Chr(10) & ""
    ' ActiveSheet.Cells(2 + 2 * i, 12 * k + 2).Value = Sheets("Sheet2").Cells(j, k + 2).Value
    ' Else
    ' ActiveSheet.Cells(2 + 2 * i, 12 * k + 2).Value = 0
    End If
    End If
    Next j
    Next i

    'Second block of alphanumerics (15 Values)
    For i = 1 To 15
    For j = 3 To MaxNumber
    If Sheets("Sheet2").Cells(j, 1).Value = ActiveSheet.Cells(1 + 2 * i, 12 * k + 6).Value Then
    If Not Sheets("Sheet2").Cells(j, Period + 2).Value = Empty Then
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 5).AddComment
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 5).Comment.Visible = False
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 5).Comment.Text Text:=Sheets("Sheet2").Cells(j, k + 2).Value 'Text:="SIRAJ:" & Chr(10) & ""
    ' Else
    ' ActiveSheet.Cells(2 + 2 * i, 12 * k + 6).Value = 0
    End If
    End If
    Next j
    Next i
    'Third block of alphanumerics (8 Values)
    For i = 1 To 8
    For j = 3 To MaxNumber
    If Sheets("Sheet2").Cells(j, 1).Value = ActiveSheet.Cells(1 + 2 * i, 12 * k + 10).Value Then
    If Not Sheets("Sheet2").Cells(j, Period + 2).Value = Empty Then
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 9).AddComment
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 9).Comment.Visible = False
    ActiveSheet.Cells(2 + 2 * i, 12 * k + 9).Comment.Text Text:=Sheets("Sheet2").Cells(j, k + 2).Value 'Text:="SIRAJ:" & Chr(10) & ""
    ' Else
    ' ActiveSheet.Cells(2 + 2 * i, 12 * k + 10).Value = 0
    End If
    End If
    Next j
    Next i

    Next k

    Not accurate though...PLs help me.. thanks. Take a look at the file I've given u as an example to check.I blif this is slightly diff coz the TT_id and theblk names seem to be in the same column in the pivot table rite??(im blur)Thankx

  12. #52
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    In this case I would start totally different.
    Let'S assume you only want to make the mapview
    I would use the raw data and do for each period and each blk the following
    -1- get the data for the cell 1 row below, 1 column before (whatever that is) [ if you have the summ up different other cells, do it in here]
    -2- get the data for the cell 1 row below, in the same column (whatever that is) [ if you have the summ up different other cells, do it in here]
    -3- get the data for the cell 1 row below, 1 column after (whatever that is) [ if you have the summ up different other cells, do it in here]

    For the summing up, do it like
    (you are searching for the number of jobs of "SearchedActBlk" in "Period")
    VB Code:
    1. for i=1 to NumberofEntriesInRawData
    2.     if RawData(i,RawDataColumn).value= SearchedActBlk
    3.        Summ=Summ+1
    4.     end if
    5. next i
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  13. #53

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    Aiyo... I don't get it..Can u pls edit the codes above and send me ..if it works for one view, i'll try to change the rest to suit my needs..Im not a programmer..me very new to all this.

  14. #54
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Try this (not tested yet)
    VB Code:
    1. Sub DisplayTTId()
    2. Dim i As Integer
    3. Dim j As Integer
    4. Dim k As Integer
    5. Dim l As Integer
    6. Dim Name As String
    7. Dim Period As Integer
    8. Dim BlkName As String
    9. Dim MaxNumber As Integer
    10. MaxNumber = 100
    11. 'for Periods 0 to 8
    12. For k = 0 To 8
    13.     'First block of alphanumerics (15 Values)
    14.     For i = 1 To 15
    15.         For j = 3 To MaxNumber
    16.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 2).Value Then
    17.                 'Count the rows that are for the same "From_blk"
    18.                 For l = j + 1 To j + 20
    19.                     TTID_Number = 1
    20.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    21.                 Next l
    22.                 For l = 0 To TTID_Number - 1
    23.                 If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
    24.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).AddComment
    25.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Visible = False
    26.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Text Text:=Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Text & Sheets("Sheet2").Cells(j, k + 2).Value
    27.                 Next l
    28.             End If
    29.         Next j
    30.     Next i
    31.     'Second block of alphanumerics (15 Values)
    32.     For i = 1 To 15
    33.         For j = 3 To MaxNumber
    34.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 2).Value Then
    35.                 'Count the rows that are for the same "From_blk"
    36.                 For l = j + 1 To j + 20
    37.                     TTID_Number = 1
    38.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    39.                 Next l
    40.                 For l = 0 To TTID_Number - 1
    41.                 If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
    42.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).AddComment
    43.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Visible = False
    44.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Text Text:=Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Text & Sheets("Sheet2").Cells(j, k + 2).Value
    45.                 Next l
    46.             End If
    47.         Next j
    48.     Next i
    49.     'Third block of alphanumerics (8 Values)
    50.     For i = 1 To 8
    51.         For j = 3 To MaxNumber
    52.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 2).Value Then
    53.                 'Count the rows that are for the same "From_blk"
    54.                 For l = j + 1 To j + 20
    55.                     TTID_Number = 1
    56.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    57.                 Next l
    58.                 For l = 0 To TTID_Number - 1
    59.                 If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
    60.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).AddComment
    61.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Visible = False
    62.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Text Text:=Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Text & Sheets("Sheet2").Cells(j, k + 2).Value
    63.                 Next l
    64.             End If
    65.         Next j
    66.     Next i
    67. Next k
    68. End Sub
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  15. #55

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    Opus.i assumed ur Sheet2 was the mapview and Sheet1 was the table...correct? For what I' run n see was there is one whole line of comments in the mapview(lets say the whole line 2).They are showing the blk details...B01,B03 etc... and some comments are empty... The TT_id is not shown at all.I've sent the file..Run the Userform and see..
    Last edited by ITboy; Apr 1st, 2003 at 03:01 AM.

  16. #56

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    with a userform for testing...
    Attached Files Attached Files

  17. #57
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    Sorry for the errors,
    this time with testing
    VB Code:
    1. Sub DisplayTTId()
    2. Dim i As Integer
    3. Dim j As Integer
    4. Dim k As Integer
    5. Dim l As Integer
    6. Dim Name As String
    7. Dim Period As Integer
    8. Dim BlkName As String
    9. Dim MaxNumber As Integer
    10. Dim CommentText As String
    11. MaxNumber = 100
    12. 'for Periods 0 to 8
    13. For k = 0 To 8
    14.     'First block of alphanumerics (15 Values)
    15.     For i = 1 To 15
    16.         For j = 3 To MaxNumber
    17.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 2).Value Then
    18.                 'Count the rows that are for the same "From_blk"
    19.                 TTID_Number = 1
    20.                 For l = j + 1 To j + 20
    21.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    22.                 Next l
    23.                 CommentText = ""
    24.                 Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).ClearComments
    25.                 For l = 0 To TTID_Number - 1
    26.                     If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
    27.                         CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
    28.                     End If
    29.                 Next l
    30.                 If Not CommentText = "" Then
    31.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).AddComment
    32.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Visible = False
    33.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Text Text:=CommentText
    34.                 End If
    35.             End If
    36.         Next j
    37.     Next i
    38.     'Second block of alphanumerics (15 Values)
    39.     For i = 1 To 15
    40.         For j = 3 To MaxNumber
    41.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 6).Value Then
    42.                 'Count the rows that are for the same "From_blk"
    43.                 TTID_Number = 1
    44.                 For l = j + 1 To j + 20
    45.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    46.                 Next l
    47.                 CommentText = ""
    48.                 Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).ClearComments
    49.                 For l = 0 To TTID_Number - 1
    50.                     If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
    51.                         CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
    52.                     End If
    53.                 Next l
    54.                 If Not CommentText = "" Then
    55.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).AddComment
    56.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Visible = False
    57.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Text Text:=CommentText
    58.                 End If
    59.             End If
    60.         Next j
    61.     Next i
    62.     'Third block of alphanumerics (8 Values)
    63.     For i = 1 To 8
    64.         For j = 3 To MaxNumber
    65.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 10).Value Then
    66.                 'Count the rows that are for the same "From_blk"
    67.                 TTID_Number = 1
    68.                 For l = j + 1 To j + 20
    69.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    70.                 Next l
    71.                 CommentText = ""
    72.                 Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).ClearComments
    73.                 For l = 0 To TTID_Number - 1
    74.                     If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
    75.                         CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
    76.                     End If
    77.                 Next l
    78.                 If Not CommentText = "" Then
    79.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).AddComment
    80.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Visible = False
    81.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Text Text:=CommentText
    82.                 End If
    83.             End If
    84.         Next j
    85.     Next i
    86. Next k
    87. End Sub
    It works with your Comments example, so its "sheet1" and so on!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  18. #58

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    Opus, it works better now BUT certain comments are not shown at all.U check properly if u dun blif me... Lets say for BLK C13 in period 2, there should be comments on 2 TT_ID but when I check the mapview, not even the comment sign is there.. And there are alot of bugs like tat...If u didn't get the picture of wat im really doing, let me tel u now.. Actually if there is a value in a cell,let's say 3, tat means the comment should show 3 TT_ids ... But from watever i tested and twisted wit my program, a TT_id comment is also visible ven though there's no value at all in the cell... Only u r capable of helping me..If u need anything for me to upload, do tel me or what u really want. Iwanted to send the whole file but its to large. I'll try to get a better pic of wat it is like if u want..Thanks for helping.

  19. #59
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    looks like, my "real" duty is interfering!
    VB Code:
    1. Sub DisplayTTId()
    2. Dim i As Integer
    3. Dim j As Integer
    4. Dim k As Integer
    5. Dim l As Integer
    6. Dim Name As String
    7. Dim BlkName As String
    8. Dim MaxNumber As Integer
    9. Dim CommentText As String
    10. MaxNumber = 100
    11. 'for Periods 0 to 8
    12. For k = 0 To 8
    13.     'First block of alphanumerics (15 Values)
    14.     For i = 1 To 15
    15.         For j = 3 To MaxNumber
    16.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 2).Value Then
    17.                 'Count the rows that are for the same "From_blk"
    18.                 TTID_Number = 1
    19.                 For l = j + 1 To j + 20
    20.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    21.                 Next l
    22.                 CommentText = ""
    23.                 Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).ClearComments
    24.                 For l = 0 To TTID_Number - 1
    25.                     If Not Sheets("Sheet1").Cells(j + l, k + 3).Value = Empty Then
    26.                         CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
    27.                     End If
    28.                 Next l
    29.                 If Not CommentText = "" Then
    30.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).AddComment
    31.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Visible = False
    32.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Text Text:=CommentText
    33.                 End If
    34.             End If
    35.         Next j
    36.     Next i
    37.     'Second block of alphanumerics (15 Values)
    38.     For i = 1 To 15
    39.         For j = 3 To MaxNumber
    40.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 6).Value Then
    41.                 'Count the rows that are for the same "From_blk"
    42.                 TTID_Number = 1
    43.                 For l = j + 1 To j + 20
    44.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    45.                 Next l
    46.                 CommentText = ""
    47.                 Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).ClearComments
    48.                 For l = 0 To TTID_Number - 1
    49.                     If Not Sheets("Sheet1").Cells(j + l, k + 3).Value = Empty Then
    50.                         CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
    51.                     End If
    52.                 Next l
    53.                 If Not CommentText = "" Then
    54.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).AddComment
    55.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Visible = False
    56.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Text Text:=CommentText
    57.                 End If
    58.             End If
    59.         Next j
    60.     Next i
    61.     'Third block of alphanumerics (8 Values)
    62.     For i = 1 To 8
    63.         For j = 3 To MaxNumber
    64.             If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 10).Value Then
    65.                 'Count the rows that are for the same "From_blk"
    66.                 TTID_Number = 1
    67.                 For l = j + 1 To j + 20
    68.                     If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
    69.                 Next l
    70.                 CommentText = ""
    71.                 Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).ClearComments
    72.                 For l = 0 To TTID_Number - 1
    73.                     If Not Sheets("Sheet1").Cells(j + l, k + 3).Value = Empty Then
    74.                         CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
    75.                     End If
    76.                 Next l
    77.                 If Not CommentText = "" Then
    78.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).AddComment
    79.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Visible = False
    80.                     Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Text Text:=CommentText
    81.                 End If
    82.             End If
    83.         Next j
    84.     Next i
    85. Next k
    86. End Sub
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  20. #60

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    Thanks a lot Opus..It works..U r angry with me? Am I troubling u too much.? U sound angry when u said ur "real " work was interfered..I know n understand the much of effort u've put into this...Thanks alot buddy.

  21. #61
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    No No, it was just that my "real" did disturb me "a bit", causing this last mistake.

    But I think this threat should be closed now!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  22. #62

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    Opus..1 more pls.. I've used ur above codes to display another comments(on Vessel names) in the 2nd cell(prev u did was for the 1st cells).I did make changes to the codes. However, when I run into that procedure, my app gets "hang" I guess something is wrong wit the code when I changed it? I can't figure out. I'll send u the pivot table Im using now(it's the same as prev one).Hope u do have the Excel sheet.I've placed the code in a module(simply codes, this file dont run)Thanks to solve my bugs.Pls..
    Attached Files Attached Files

  23. #63
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    two mistakes in there:
    VB Code:
    1. Sub VesselComments1()
    2. Dim i As Integer
    3. Dim j As Integer
    4. Dim k As Integer
    5. Dim l As Integer
    6. Dim Name As String
    7. Dim Period As Integer
    8. Dim BlkName As String
    9. Dim MaxNumber As Integer
    10. Dim CommentText As String
    11. Dim Vessel_Number As Integer
    12. MaxNumber =[b] 300[/b]
    13. Sheets("mapview").Activate
    14. 'for Periods 0 to 8
    15. For k = 0 To 8
    16.     'First block of alphanumerics (15 Values)
    17.     For i = 1 To 15
    18.         For j = 3 To MaxNumber
    19.             If Sheets("sparePivot").Cells(j, 1).Value = Sheets("mapview").Cells(1 + 2 * i, 12 * k + [b]2[/b]).Value Then
    20.                 'Count the rows that are for the same "From_blk"
    21.                 Vessel_Number = 1
    22.                 For l = j + 1 To j + 20
    23.                     If Sheets("sparePivot").Cells(l, 1).Value = Sheets("sparePivot").Cells(j, 1).Value & " Total" Then Vessel_Number = l - j
    24.                 Next l
    25.                 CommentText = ""
    26.                 Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).ClearComments
    27.                 For l = 0 To Vessel_Number - 1
    28.                     If Not Sheets("sparePivot").Cells(j + l, k + 3).Value = Empty Then
    29.                         CommentText = CommentText & Sheets("sparePivot").Cells(j + l, 2).Value & Chr(10)
    30.                     End If
    31.                 Next l
    32.                 If Not CommentText = "" Then
    33.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).AddComment
    34.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).Comment.Visible = False
    35.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).Comment.Text Text:=CommentText
    36.                 End If
    37.             End If
    38.         Next j
    39.     Next i
    40.     'Second block of alphanumerics (15 Values)
    41.     For i = 1 To 15
    42.         For j = 3 To MaxNumber
    43.             If Sheets("sparePivot").Cells(j, 1).Value = Sheets("mapview").Cells(1 + 2 * i, 12 * k + [b]6[/b]).Value Then
    44.                 'Count the rows that are for the same "From_blk"
    45.                 Vessel_Number = 1
    46.                 For l = j + 1 To j + 20
    47.                     If Sheets("sparePivot").Cells(l, 1).Value = Sheets("sparePivot").Cells(j, 1).Value & " Total" Then Vessel_Number = l - j
    48.                 Next l
    49.                 CommentText = ""
    50.                 Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).ClearComments
    51.                 For l = 0 To Vessel_Number - 1
    52.                     If Not Sheets("sparePivot").Cells(j + l, k + 3).Value = Empty Then
    53.                         CommentText = CommentText & Sheets("sparePivot").Cells(j + l, 2).Value & Chr(10)
    54.                     End If
    55.                 Next l
    56.                 If Not CommentText = "" Then
    57.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).AddComment
    58.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).Comment.Visible = False
    59.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).Comment.Text Text:=CommentText
    60.                 End If
    61.             End If
    62.         Next j
    63.     Next i
    64.     'Third block of alphanumerics (8 Values)
    65.     For i = 1 To 8
    66.         For j = 3 To MaxNumber
    67.             If Sheets("sparePivot").Cells(j, 1).Value = Sheets("mapview").Cells(1 + 2 * i, 12 * k + [b]10[/b]).Value Then
    68.                 'Count the rows that are for the same "From_blk"
    69.                 Vessel_Number = 1
    70.                 For l = j + 1 To j + 20
    71.                     If Sheets("sparePivot").Cells(l, 1).Value = Sheets("sparePivot").Cells(j, 1).Value & " Total" Then Vessel_Number = l - j
    72.                 Next l
    73.                 CommentText = ""
    74.                 Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).ClearComments
    75.                 For l = 0 To Vessel_Number - 1
    76.                     If Not Sheets("sparePivot").Cells(j + l, k + 3).Value = Empty Then
    77.                         CommentText = CommentText & Sheets("sparePivot").Cells(j + l, 2).Value & Chr(10)
    78.                     End If
    79.                 Next l
    80.                 If Not CommentText = "" Then
    81.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).AddComment
    82.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).Comment.Visible = False
    83.                     Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).Comment.Text Text:=CommentText
    84.                 End If
    85.             End If
    86.         Next j
    87.     Next i
    88. Next k
    89. End Sub
    Interested in a code that does all three at same time???
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  24. #64

    Thread Starter
    Lively Member
    Join Date
    Mar 2003
    Location
    singapore
    Posts
    86
    ooooooohhh! why not, if u have the time to help me? U mean it will display all three fields at one go for the same blk against the periods? interesting... though all these works, actually im quite worried with my long chunky code(ugly) and wish to optimize them nicely.. Jus now ur solution hanged too..but dun worry.I've fixed that problem using Application.ScreenUpdating=False I think too tat tis thread is too long already.When u reply to me can u send me a private msg on wat ur thread title is about so tat i can get back to u if u have the solution or something else we can share..Thanks buddy

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width