Solved

Openoffice macro

Posted on 2014-12-09
6
229 Views
Last Modified: 2015-01-04
Hi Experts,

I have a openoffice odt file.
It has 2 sheets .Sheetname is Eg.Dec1,Dec2
Each sheet has the same formatted data.
Eg.
Sheet1
ColumnB ColumnC
Task1           4
Task2            1
Sheet2
ColumnB ColumnC
Task1           2
Task2            3

The output i am looking is as below.
Newfile-Sheet1
ColumnA ColumnB ColumnC
Task1         4                 2
Task2          1                 3

Is this possible in (Openoffice)Odt excel?

Thanks
0
Comment
Question by:magento
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 40489436
What is (Openoffice)Odt excel?

can you use VBA there ? if yes then the answer to your request is YES.
gowflow
0
 
LVL 20

Expert Comment

by:ltlbearand3
ID: 40492893
You may want to have the mods change your topics as there really is no thing called Open Office Excel.  They have a program called Calc that is very similar and I am guessing that is what you are using.  There is the ability to write custom codes/macros in Calc but they do not us VBA like Microsoft products.  I can help you work through getting a macro running, but I don't know that I fully understand what you want.  

Are you just wanting to take two sheets and combine them into one sheet?  Is this an ongoing task?  Is the data in both sheets sorted and is the task list the same on both sheets?  If so, why not just copy and paste?  If a value is only in one list, what do you want to happen?  

You basic question was if this was possible.  The answer is very likely yes, but how we do it may vary substantially based on the details.
0
 
LVL 5

Author Comment

by:magento
ID: 40499552
Hi ltlbearand3,

Apologies for the confusion, Yes i use calc.

For ur questions, the order wont be sorted, i can just copy paste it, but there are more than 2 sheets . Hence i am looking for a way to automate this work.

Thanks
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 20

Expert Comment

by:ltlbearand3
ID: 40499590
Ok.  I will see if I can post some starter code tonight or tomorrow. A few more questions.  Do all sheets contain all the tasks and are the tasks in the sheets in the same order?  Is this a one time process or will it be run multiple times on this sheet (i.e. will this be a reoccurring item?)
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
ID: 40504178
I made a couple assumptions, but here is some macro code that should work for you.  It takes the first sheet and copies all data in columns B & C to a new workbook.  It then takes column C from all the other sheets and copies then one column over in the new sheet.  

' ExpertExchange Question ID 28577243
' http://www.experts-exchange.com/Software/Office_Productivity/Spreadsheets/Q_28577243.html
' Expert: ltlbearand3 [http://www.experts-exchange.com/M_2469312.html]
'

Sub Main
	Dim oDocOrig as object
	dim oDocNew as object
	Dim oSheetCurrent as object
	Dim oSheetNew as object
	Dim oRangeOrig as object
	Dim oRangeNew as object
	Dim oCursor as object
	Dim oRangeCopy as object
	Dim intLastRow as integer
	Dim i as integer
	
	' Get access to the current Workbook
	oDocOrig = ThisComponent
	
	' Create the New Workbook and access the new Sheet
	oDocNew = StarDesktop.loadComponentFromUrl("private:factory/scalc", "_blank",0,dimArray())
	oSheetNew = oDocNew.Sheets.getByIndex(0)
	oSheetNew.Name = "Master"
	
	' Copy the Data from the First Sheet over to the Master Including the Task List
	oSheetCurrent = oDocOrig.Sheets.getByIndex(0)

	' Find the Last Row of Data
	oCursor = oSheetCurrent.createCursor()
	oCursor.gotoEndOfUsedArea(False)
	intLastRow = oCursor.getRangeAddress().endRow
	
	' Set up the Copy Ranges
	' Parameters for RangeByPositions are (left, top, right, bottom)
	oRangeOrig = oSheetCurrent.getCellRangeByPosition(1,0,2,intLastRow).getDataArray
	oRangeNew = oSheetNew.getCellRangeByPosition(0,0,1,intLastRow)
	oRangeNew.setDataArray(oRangeOrig)
	
	' Now Loop Through the rest of the sheets
	For i = 1 to oDocOrig.Sheets.Count-1
		oSheetCurrent = oDocOrig.Sheets.getByIndex(i)

		' Set up the Copy Ranges
		oRangeOrig = oSheetCurrent.getCellRangeByPosition(2,0,2,intLastRow).getDataArray
		oRangeNew = oSheetNew.getCellRangeByPosition(i+1,0,i+1,intLastRow)
		oRangeNew.setDataArray(oRangeOrig)
	Next

End Sub

Open in new window

0
 
LVL 5

Author Closing Comment

by:magento
ID: 40531014
Thanks
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This article will shed light on the latest trends when it comes to your resume building needs. For far too long, the traditional CV format has monopolized the recruitment market.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question