Solved

Openoffice macro

Posted on 2014-12-09
6
226 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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

I recently resolved a client's Office 2013 installation problem and wanted to offer an observation that may help you with troubleshooting similar issues. The client ordered three Dell Optiplex system units with the Windows 7 downgrade option inst…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now