?
Solved

Openoffice macro

Posted on 2014-12-09
6
Medium Priority
?
244 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 31

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
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

752 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