Solved

Openoffice macro

Posted on 2014-12-09
6
227 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modifying Conditional Format from VBA code 3 55
I need help embedding an image as HTML in my vb.net application 3 67
Simple Google Sheets Script question. 2 30
Excel 2013 13 49
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

773 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