Solved

Openoffice macro

Posted on 2014-12-09
6
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 30

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
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 shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

688 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