Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I have a couple of questions regarding macros and excel. 1. I have a vba function that prints data to a text file. It's in columns. How do I align all the data into the correct column. I' guessing I have to right justify this,but i don't know how. Can someon help me with this? 2. When I create a chart using vba, it keeps adding new charts when run the program. How do i make it overwrite the current chart -- NewGuy10 ----------------------------------------------------------------------- NewGuy100's Profile: http://www.excelforum.com/member.php...fo&userid=2793 View this thread: http://www.excelforum.com/showthread.php?threadid=47545 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
#1:
http://google.com/groups?threadm=015...0a% 40phx.gbl #2: How about just deleting the existing chart before your code adds the new one? NewGuy100 wrote: I have a couple of questions regarding macros and excel. 1. I have a vba function that prints data to a text file. It's in 6 columns. How do I align all the data into the correct column. I'm guessing I have to right justify this,but i don't know how. Can someone help me with this? 2. When I create a chart using vba, it keeps adding new charts when i run the program. How do i make it overwrite the current chart? -- NewGuy100 ------------------------------------------------------------------------ NewGuy100's Profile: http://www.excelforum.com/member.php...o&userid=27935 View this thread: http://www.excelforum.com/showthread...hreadid=475455 -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
RE #1 I assume you know the width of each column so you have to add leading
spaces before each item to make its length equal to the current column's width. You might find that using the RSet statement makes this a little simpler. -- Jim "NewGuy100" wrote in message ... | | I have a couple of questions regarding macros and excel. | | 1. I have a vba function that prints data to a text file. It's in 6 | columns. How do I align all the data into the correct column. I'm | guessing I have to right justify this,but i don't know how. Can someone | help me with this? | | 2. When I create a chart using vba, it keeps adding new charts when i | run the program. How do i make it overwrite the current chart? | | | -- | NewGuy100 | ------------------------------------------------------------------------ | NewGuy100's Profile: http://www.excelforum.com/member.php...o&userid=27935 | View this thread: http://www.excelforum.com/showthread...hreadid=475455 | |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
1. Let's say you need to take the values in the range A1:F5 and convert to
text with each column filling 10 spaces (right justified). Dim LineOfData As String For i = 1 to 5 ' for the rows LineOfData = "" ' build new string for each line For j = 1 to 6 ' for the columns LineOfData = LineOfData & Right(Space(10) & Worksheet("SheetName").Cells(i,j).Text,10) ' Spaces to pad, Right function ensures result is 10 characters long Next j ' Write the line of data to your file here Next i 2. You must be doing a Charts.Add (or ChartObjects.Add) and, naturally, this will add a chart each time it is run. Perhaps the easiest thing to do given your situation now would be to add a line to delete the existing chart, e.g. ThisWorkbook.Charts(1).Delete (for a chart sheet) or ActiveSheet.ChartObjects(1).Delete (for an embedded chart), and then to build the new one. It would be cleaner to have created the initial chart as part of your workbook design and then used your code just to change the parts that need updating each time it is run, but by now that would mean reworking a lot of your code. -- - K Dales "NewGuy100" wrote: I have a couple of questions regarding macros and excel. 1. I have a vba function that prints data to a text file. It's in 6 columns. How do I align all the data into the correct column. I'm guessing I have to right justify this,but i don't know how. Can someone help me with this? 2. When I create a chart using vba, it keeps adding new charts when i run the program. How do i make it overwrite the current chart? -- NewGuy100 ------------------------------------------------------------------------ NewGuy100's Profile: http://www.excelforum.com/member.php...o&userid=27935 View this thread: http://www.excelforum.com/showthread...hreadid=475455 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Is there a function to check if a chart exists -- NewGuy10 ----------------------------------------------------------------------- NewGuy100's Profile: http://www.excelforum.com/member.php...fo&userid=2793 View this thread: http://www.excelforum.com/showthread.php?threadid=47545 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Answers to questions posing more questions in a workbook | Excel Worksheet Functions | |||
Excel Questions | Excel Discussion (Misc queries) | |||
View Questions and Answer to questions I created | Excel Discussion (Misc queries) | |||
Excel Add in questions... | Excel Discussion (Misc queries) | |||
Excel/VBA Questions | Excel Programming |