I'm writing a macro to pull some values from a database, but I need it to skip the write to report if the value =(x).
Basically if my object string is equal to 0019, 0057, or , 0064 then I don't want it to write to my excel document.
Any ideas?
Hey Guys thanks for the suggestion, I ended up setting my IF statements to not equal to those 3 values and write to report everything else.
Related
I'm trying to program a macro in excel to export data to a word report. This data will go into several Word tables. All data transfer commands are now ready and working. However, in order to make this transfers more dynamic, I am inserting Titles and creating bookmarks for all tables into word report.
The problem is:
Via excel macro, I am able to select the Word tables through the following code:
oDoc.Bookmarks("Table_name").Range.Select
However, I cannot transfer the data to a specific cell of this table.
I know the by Word there is this command, but I can't use with Excel.
ActiveDocument.Range(0,Selection.Paragraphs(1).Range.End).Tables.Count)
Would anyone know how to help me?
Before that I was transferring the data referencing the table number but the problem is that whenever we revise the report to include new tables my reference ends up getting lost and I have to do table count again to transfer the data in the right table .
Well, that's it! Thanks in advance if anyone can help me.
It entirely depends on how your document is constructed. If the bookmarks enclose content, then you can use:
oDoc.Bookmarks("Table_name").Range.Tables(1)
MS Word does not give each one a name, so you have to come up with your own system.
When you create the document with all the tables, you can give each one a name... using the Table.Descr property.
ActiveDocument.Tables(1).Descr = "myTable"
Then when you look for them, loop thru them and find that Descr
For Each t In ActiveDocument.Tables
If t.Descr = "myTable" Then
' do something
End If
Next
Or you can set up some constants for the Index if that helps.
Or you can create one routine that sets up variables by scanning the document that you would need to run only once.
I'm trying to process an excel , I need to generate una excel file for each row and as filename I need to use one of the fields in the row.
The excel output hasn't the option "Accept filename from field" and I can't figure out how to achieve it.
thanks
You need to copy the rows into memory and then loop it across the excel file to generate multiple files. You need to break your solution to 2 parts. First of all, read all the rows from Excel Input step into "Copy rows to Result" step as a variable. In the next transformation, use the same variable to use it as a file parameter.
Please check the two links:
SO Similar Question: Pentaho : How to split single Excel file to multiple excel sheet output
Blog : https://anotherreeshu.wordpress.com/2014/12/23/using-copy-rows-to-result-in-pentaho-data-integration/
Hope this helps :)
The issue is that the step is mostly made for outputting the rows to a single file, not making a file for each row.
This isn't the most elegant solution but I do think it will work. From your transformation you can call a sub-transformation (Mapping) and send a variable to it containing the filename. The sub-transformation can simply do one thing: write the file, and it should work fine. Make sense?
I have a file (only one) with some columns with integer numbers. When I change and save file, those columns are automaticaly converted in dates. Does anyone knows how can i prevent this? Thank You!
you might want to check out a similar issue here:
http://www.mrexcel.com/forum/excel-questions/637277-excel-converting-numbers-dates.html
(the below suggestions might not be particularly relevant to this issue, but in general, they might help to resolve such a problem)
Selct the cells and go to Format --> cells --> number and select Text for the selection
There's also a one-keystroke solution: type an apostrophe before entering or pasting a pair of numbers that Excel could mistake for a date and month. When you exit the cell, the apostrophe vanishes and the numbers stay numbers, formatted as text.
this is what microsoft says:
http://office.microsoft.com/en-001/excel-help/stop-automatically-changing-numbers-to-dates-HA102809473.aspx
also if you are pasting data from somewhere else
try Paste Special
I guess there is still no solutions to this problem.
It happens in both my computers when inserting data from sql server 2008.
Half of columns becomes dates..... and im supposed to give this to my accountant.. sucks
(Btw i know about the special paste to text, then convert to number... but it takes so much time)....
I just ran into this issue. I am using a webhook to store data to excel on the fly, adding new rows, updating existing data, etc.
I had a special field "step" which is a string who can be "1", "1.1", "1.2", etc. which was treated as date as soon as the value was a "string decimal"...
The only way I could find to fix this issue was to programmatically add a ' before the value, like '1.2.
I tried to apply this to all my fields to avoid excel side effect, but I then noticed that when updating an existing row by merging new values with existing values then the ' was stripped. So, I end up using a whitelist of fields to escape. I couldn't locate the fields to force adding ' when merging data due to limitations from the lib I use google-sheets-node-api.
I am stuck having to query a SQL Server database that is mimicking SQL server 2000 database and no way around it.
I have a large result set of 5 fields. The last field is a memo field. The result set is so large in SSMS 2012 that I cannot select them all with headers. So I have to save to Excel csv format. In doing so it interprets data in the 5th field as either a function (“-“, “+”, “(space) –“, “(space)+”, etc at the beginning) or as multiple columns for various reasons.
So far I have
replace(ltrim(rtrim(memo)), ',', ' ') as Memo
This, of course, trims beginning and end and replaces commas with spaces. I do not want to have to build nested replaces unless I must. This is for a large audit report that is not run often so I can, if need be, use a function.
Is there a good way to make a field like this compliant with Excel so that Excel will just keep that field as one column? I would appreciate any insight.
It seems that the correct method is to append double quotes to the beginning and the end of the field value returned in the query. As I am having to right-click and output to Excel this methods works and Excel does not misinterpret the intent.
Brief description of what i want my VBA to achieve: I'm trying to import data from two Excel spreadsheets, and then compare the data on each list to find the missing elements in each list and then highlight the data row if it is missing.
Well there is a certain kind of order required to run Differences. Import_buttonx has to be called before Differences can be called. So you get an out of index because stringOfSheet(1,2) probably ha no value. It's probably nil. You can check while debugging through your code.