PDA

View Full Version : Sleeper: Text problem



Dreamer
07-07-2005, 05:05 PM
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!

Anne Troy
07-07-2005, 10:54 PM
No offense, but I don't understand the point or the question. :p

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

Bob Phillips
07-08-2005, 02:05 AM
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

excelliot
07-08-2005, 05:58 AM
is this helpful to u :*) (http://www.vbaexpress.com/kb/getarticle.php?kb_id=289):*) (http://www.vbaexpress.com/kb/getarticle.php?kb_id=289)

Dreamer
07-08-2005, 08:18 AM
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..

Bob Phillips
07-08-2005, 09:44 AM
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.


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?

Dreamer
07-08-2005, 10:50 PM
Hi Xld,

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

Bob Phillips
07-09-2005, 02:11 AM
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?

Dreamer
07-09-2005, 05:42 AM
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?