I have an ssrs report that sums a column for a total, like so:
=Sum(CDEC(Fields!Month01Balance.Value))
Now, when exporting to excel this does not export as a formula. I was told there is a way to do it using the ReportFields collection, however I cannot get that to work. Does anyone know of a way I can get a total column to export a formula to excel? I don't know how many rows there will be so I cannot manually reference each ReportField text box.
Thanks for any pointers here!
You must replace the VALUE of the cell with text representing the formula, but the formula must be preceded by a single apostrophe: e.g.,
A | B | C
2 | 4 | 6
Becomes:
A | B | C
2 | 4 | '=A1+B1
When you export the report to Excel, replace all the single apostrophes with [nothing]. The formulas should now run.
Suggestion: Create a new boolean report parameter called "Show_Formulas." Then, write an expression for field C: =IIF(Parameters!ShowFormulas.Value,"'=A" & RowNumber("myQuery") & "+B" & RowNumber("myQuery"),Fields!C.Value)
This way, the enduser can either see the values in the report, or re-run the report showing the formulas for export.
Related
I have text in column A and URLs in column B.
I want the merged A&B shown in column C.
Example:
Column A | Column B | Column C
Product 1 | google_dot_com | Product 1 (with hyperlink to url)
Product 2 | yahoo_dot_com | Product 2 (with hyperlink to url)
Product 3 | stackoverflow_dot_com | Product 3 (with hyperlink to url)
Here is an image.
This is different from just referencing the cells and using the HYPERLINK(A1,B1) and then copying it down column C.
Here is a small test file I created that you can download if my above example wasn't clear enough. http://www.filedropper.com/stacker-help
Using Microsoft Office Professional Plus 2013, Windows 7
=HYPERLINK(B2,A2) should work as per your image requirement. Please check
store the link(column B) in text format
Use the CONCATENATE-Funktion in Excel, e.g.=CONCATENATE(A1;B1).
If you need the square bracets just add them in eg.g =CONCATENATE(A1;"[";B1;"]").
The function-names in Excel depend on your language, you might have to use a translated version (in Germany 'VERKETTEN', other languages see http://en.excel-translator.de/CONCATENATE/).
And it gets better: in german you need ";" to seperate the parameters, in english it's a ",".
Translating funktion-names like in Excel should be considered a crime.
I have found the answer I was looking for, here is the VBA code I used.
Sub MergingCells()
For i = 2 To Range("a1").End(xlDown).Row
Sheets("sheet1").Hyperlinks.Add anchor:=Cells(i, 3), Address:="http://" & Cells(i, 2).Value, TextToDisplay:=Cells(i, 1).Value
Next i
End Sub
I have a macro in file, and what I need to do is to run a query in it, as it was a SQL table, or find a similar code in VBA. Almost everything I found about it, was about running a query in Access database using VBA in an Excel file.
In my file I have a Sheet that I need to use as database, and a second Sheet that need to show some information when I run a macro. Imagine that I have a sheet like this:
|Number|Field1|
| 5 |AAAAAA|
| 4 |BBBBBB|
| 8 |CCCCCC|
| 3 |AAAAAA|
| 4 |BBBBBB|
| 2 |AAAAAA|
| 1 |CCCCCC|
This query should sum only the numbers where Field1 has a determined value, and should sum all the lines in the sheet. The number of lines vary depending the day.
Is it possible to do something like this?
I suggest the sumif forumla. (So, you don't need a macro for that):
=SUMIF(B2:B8;"BBBBBB";A2:A8)
This sums the numbers in A2 to A8 if the mathching rown in B2 to B8 contains "BBBBBB"
Given
O 1 2 3 A
A 4 5 6 B
B 7 8 9 D
O 3
C 15
T 18
I'm looking for VBA code to validate that when column A contains a value that the remaining columns also contain values and when it doesn't contain a value, that columns 2 & 5 also contain values but 3 & 4 don't.
I've simplified the example, in a real sheet there will be many more columns and rows to check.
I've considered COUNTIF and INDEX/MATCH and array forumlas but from my understanding these all work on single columns at a time.
I want to do something like WHEN A1:An<>"" THEN COUNTBLANK(B:E) ELSE COUNTA (C:D)
Is the best way to use autofilter using blanks in A and then countblank and then a second autofilter for values in A.
Thanks
You can do it with a couple of nested IF formulae as follows:
=IF(A1<>"",
"A not empty, "&IF(COUNTBLANK(B1:E1)=0,
"B:E not blank",
"B:E have blanks"),
"A blank, "&IF(AND(COUNTBLANK(B1)+COUNTBLANK(E1)=0,
COUNTBLANK(C1)+COUNTBLANK(D1)=2),
"Columns 2&5 have values and Columns 3&4 don't",
"but condition not met"))
The reason for going down the VBA route is that I want a generic reusable function as opposed to a formula I copy between cells and sheets changing the columns etc along the way ending up with a lot of duplicate code.
So something that takes a column to test and a value to test it with. Third parameter would be a range of columns to validate, and the fourth parameter the validation.
I don't want any solution to have the columns hard coded and I don't want intermediate totals at the end of rows. This is fairly easily achieved in Excel itself...
The reason for trying to use countblank is that I can apply it to a range.
After a lot of searching I discovered this (the columns don't match the original example)
=SUMPRODUCT((A2:A19<>"")*(B2:D19=""))
=SUMPRODUCT((A2:A19="")*(D2:D19=""))
=SUMPRODUCT((A2:A19="")*(B2:C19<>""))
Nice huh? I just need to convert it into VBA now.
Thanks
I got a problem with Excel 2007 where I cannot find a solution to. I think one has to use VBA to do it by I am pretty unexperienced with that.
I have a dataset in Excel (about 1k lines) with 10 columns. In an other tab/worksheet, I now want to display the data filtered by one column (country codes). It can be done dirty with autofiltering but it should be more like a report so it has to look good.
Let me make an example what I mean:
DATASET
Column | Column 2 | Column 3
Hans | GER | 16
Peter | US | 29
Maria | GER | 30
Darian | US | 15
Lisa | GER | 40
In an other Tab/Worksheet, I now want an automatically updated, formatted and filtered list based on this data set, e.g.:
REPORT
Germany
Hans | 16
Maria | 30
Lisa | 40
US
Peter | 29
Darian | 15
I hope you understand what I mean. If I add new lines of data in my dataset sheet, I want the report to be automatically updated (so I can't just but autofilter lists below each other because the number of rows which will be needed depends on the data points). I think this should be pretty easy to do using a VBA macro, but I have no clue how to do it... Help very much appreciated!
Thanks upfront!
*
Have you tried a PivotTable combined with a dynamic named range?
Given your data set above is set up in Sheet1 of your workbook, starting in A1 with column names. See the following solution.
1) Enter a dynamic named range for your dataset, like below.
This will ensure that any new data that is added to the end, or inserted into the middle of the data set gets captured and updated automatically with a pivot table refresh.
2) Base your pivot table on the Named Range.
3) Finally, set up your PivotTable like below.
You can then format your pivot table how you like.
A Pivot table can do the type of grouping you are looking for. Using the data you provided, this is what I get from a pivot table:
I suggest you take a look at pivot tables. they can be a bit complicated but once you figure out how they work they are very useful.
I am using macros in excel 2007 for my work. I am working with many data and I need to sum data from 2 or more rows in the same coloumn according to the same month. However the month column is expressed as date.
for example, i have series of data
A B
2/10/2008 2
2/10/2008 3
4/10/2008 3
5/11/2008 4
5/11/2008 5
I want the result to be displayed in column C and D as followed
C D
Oct/08 8
Nov/08 9
I am very thankful if anyone can help me.
regards,
Tifu
A B C D E F
1 10/ 1/2008 24106 1 Oct-08 24106 8
2 10/31/2008 24106 7 Nov-08 24107 11
3 11/ 1/2008 24107 8 Dec-08 24108 6
4 11/30/2008 24107 3
5 12/ 1/2008 24108 2
6 12/ 2/2008 24108 4
B1 =MONTH(A1)+YEAR(A1)*12
E1 =MONTH(D1)+YEAR(D1)*12
F1 =SUMIF(B$1:B$6,CONCATENATE("=",E1),C$1:C$6)
I had to overcome two problems to solve this. First, SUMIF can only do direct comparison, it cannot run a function on the source location (except for range functions, which the date and time functions are not), so I had to add the B column. The E column is optional, it could be implemented as part of the formula in F, but I left it independent for illustrative purposes. Second, SUMIF takes a string parameter describing the comparison, so I built the necessary string (it is "=24106" for F1) on the fly.
using array functions:
C1:
=date(2008,small(month($A$1:$A$10),1),1)
C2:
=date(2008,small(month($A$1:$A$10),2),1)
right click on these cells and format them as mmm/yy
D1:
=sum(if(month($C1)=month($A$1:$A$10),($B$1:$B$10),0))
make sure to press ctrl-shift-enter when done writing this formula.
then copy an paste it down as needed.
If you are unfamiliar with VBA, I would start off by recording a macro while doing what you want to do by using the Subtotals feature under the Data menu (i.e. through Excel's interface).
Once the macro is recorded, you can look at the VBA code produced, and alter it to suit your needs.
This should be possible to do using regular excel formulas:
extract the month of the date (some Month-function)
then do a conditional sum (function sumwhen (?)) like this:
= SumWhen(A:B, ReferenceDate, B:B)
(with ReferenceDate = C2 C3 etc.)
(All I have is a German excel and the function names got translated as well, so my function names may be off. Maybe someone can check against an English excel and update if necessary.)