Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel and Vba questions


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel and Vba questions

#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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Excel and Vba questions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Excel and Vba questions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel and Vba questions


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
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
Answers to questions posing more questions in a workbook sbelle1 Excel Worksheet Functions 2 August 8th 09 01:02 AM
Excel Questions rainonu Excel Discussion (Misc queries) 4 December 7th 08 01:00 PM
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
Excel Add in questions... hunter_alexander Excel Discussion (Misc queries) 0 June 26th 07 09:53 PM
Excel/VBA Questions Chris Excel Programming 2 May 20th 04 08:11 PM


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