2 for the price of 1

dazzerj

New Member
Joined
Jul 14, 2011
Messages
3
Hello Clever Ones,

With the help of this forum I managed to create my first macro within excel (see below). I would like to enhance the export activity by selecting an email recipient with the generated xml file as an attachment. Is this possible within Excel, to invoke an email message?

My 2 for 1 is below the truncated code below (the second question may be simpler to answer, it's not a coding query just an excel behaviour).

I'm sure there is probably a more efficient way of achieving what I have here, but as a complete novice if you have suggestions for streamlining please give an explanation of any functions introduced.

Here is a description of what it is doing.

On sheet 1 I have a number of check box items. When each is checked the contents of 4 associated cells are written into sheet 2. This macro outputs the content of sheet 2 (omitting blank rows) into an xml file. Sweet.


Sub OutputXML()
Open "C:\Documents and Settings\Darren.Jones\Desktop\CusPk-test.xml" For Output As #1
Print #1, Sheets("Sheet2").Cells(1, 1) & Chr(13) & Sheets("Sheet2").Cells(2, 1) & Chr(13) & Sheets("Sheet2").Cells(3, 1) & Chr(13) & Sheets("Sheet2").Cells(4, 1) & Chr(13) & Sheets("Sheet2").Cells(5, 1) & Chr(13) & Sheets("Sheet2").Cells(6, 1) & Chr(13) & Sheets("Sheet2").Cells(7, 1) & Chr(13) & Sheets("Sheet2").Cells(8, 1) & Chr(13) & Sheets("Sheet2").Cells(9, 1) & Chr(13) & Sheets("Sheet2").Cells(10, 1) & Chr(13) & Sheets("Sheet2").Cells(11, 1) & Chr(13) & Sheets("Sheet2").Cells(12, 1) & Chr(13) & Sheets("Sheet2").Cells(13, 1) & Chr(13) & Sheets("Sheet2").Cells(14, 1) & Chr(13) & Sheets("Sheet2").Cells(15, 1) & Chr(13) & Sheets("Sheet2").Cells(16, 1) & Chr(13) & Sheets("Sheet2").Cells(17, 1) & Chr(13) & Sheets("Sheet2").Cells(18, 1) & Chr(13) & Sheets("Sheet2").Cells(19, 1)
If Len(Sheets("Sheet2").Cells(20, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(20, 1)
If Len(Sheets("Sheet2").Cells(21, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(21, 1)
If Len(Sheets("Sheet2").Cells(22, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(22, 1)
If Len(Sheets("Sheet2").Cells(23, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(23, 1)
If Len(Sheets("Sheet2").Cells(24, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(24, 1)
If Len(Sheets("Sheet2").Cells(25, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(25, 1)
If Len(Sheets("Sheet2").Cells(26, 1)) > 0 Then Print #1,
...

If Len(Sheets("Sheet2").Cells(90, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(90, 1)
If Len(Sheets("Sheet2").Cells(91, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(91, 1)
If Len(Sheets("Sheet2").Cells(92, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(92, 1)
If Len(Sheets("Sheet2").Cells(93, 1)) > 0 Then Print #1, Sheets("Sheet2").Cells(93, 1)
Close
End Sub


Here's the second question.

In the spreadsheet sheet 1 that this macro resides in, I have 4 output lines associated with check box items, of which here are currently 18. Totalling 72 lines of output. In sheet 2 I have used the IF function to fill in the content of a cell e.g. =IF(Sheet1!A5,Sheet1!D3,""). This function works perfectly for all rows in Sheet 2 upto Row 69 at which point it stops performing and the content of the cell always shows the formula and not the result. If I move the formula to the next column it starts to return the correct result. No matter what I try though it will not give the result any longer in any row beyond 69 in column 1!

Is there a limit to how many formulas can exist in a single column? I am perplexed.

All assistance greatly appreciated.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,224,586
Messages
6,179,722
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top