Consulting

Results 1 to 9 of 9

Thread: Sleeper: Text problem

  1. #1

    Sleeper: Text problem

    Hi all,

    I want to write 3 sentences in every three empty rows:

    Monthly Income: May
    XXXXXX
    XXXXXXXX
    XXXXXXXXX
    (Blank row) --> write in -> A: May
    (Blank row) --> write in -> B: May
    (Blank row) --> write in -> C: May
    Monthly Income: June
    XXxXX
    XXXx
    (Blank row)--> write in -> A: June
    (Blank row)--> write in -> B: June
    (Blank row)--> write in -> C: June
    Monthly Income: July
    ..........
    .....

    First sentence- A &":"&"Text after : "
    Second sentence- B &":"&"Text after : "
    Third sentence- C &":"&"Text after : "

    I have no idea on how to store the text such as "May","June" .. so that it can later help to write texts in empty rows. However, these texts are all followed by a ":", in places just in near above..

    I would be grateful if anyone can help, Thanks!

  2. #2
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    No offense, but I don't understand the point or the question.

    To me it seems like you're trying to do something you could easily do with existing data and a Word mail merge.
    ~Anne Troy

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sub MonthlyIncome()
    Dim i As Long
    Dim iLastRow As Long
    Dim sdata As String
    Dim iLetter As Long
    iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
        For i = 1 To iLastRow + 3
            If Left(Cells(i, "A").Value, 16) = "Monthly Income: " Then
                sdata = Right(Cells(i, "A").Value, Len(Cells(i, "A").Value) - 16)
                iLetter = 65
            ElseIf Cells(i, "A").Value = "" Then
                Cells(i, "A").Value = Chr(iLetter) & ": " & sdata
                iLetter = iLetter + 1
            End If
        Next i
    End Sub

  4. #4
    A mighty flame followeth a tiny sparkle!!



  5. #5
    I know my writing is not good
    Hi all, Thx for your reply..

    Hi Xld, what if there are many variable names...
    e.g. Monthly Income, Annual Income, Average Income..
    then I cannot fix the length of 16..

    and A,B,C could be Total, Mean, Average..
    I know I should modify it myself, but my current level cannot handle this..

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Dreamer
    IHi Xld, what if there are many variable names...
    e.g. Monthly Income, Annual Income, Average Income..
    then I cannot fix the length of 16..
    That is straight-forward enough.

    Quote Originally Posted by Dreamer
    and A,B,C could be Total, Mean, Average.
    Do you mean we should use Total, Mean and Average instead of ABC, and then what?

  7. #7
    Hi Xld,

    Thanks for your help.
    Total, Mean and Average is one of real cases...
    There are many sheets with different names though..

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Dreamer
    Hi Xld,

    Thanks for your help.
    Total, Mean and Average is one of real cases...
    There are many sheets with different names though..
    I'm not getting how we know what text to use in there?

  9. #9
    Hi,

    Hm... for those sentences,e.g Monthly salary: May,
    those cells will be hightlighted in yellow,
    and you can find them all when you see there is a ":" ...

    Is It possible?

Posting Permissions

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