I have the following issue:
I have feature recommendations for specific types of software packages listed on a picklist.
On another sheet I enter several software packages and when I start a new row with a nee software package, this sheet should tell me which features are possible or recommended for the type of software package I have chosen for my new package.
This is done with a VLOOKUP which has its matrix on the picklist and this works fine.
However in case the recommendations change on the picklist for future software packages I have a problem. Because if i change the recommendations on the picklist, the data get changed also for packages I have entered in the past however the new changes should only apply for packages entered in the future.
A solution would be that I could "freeze" rows where I have entered past packages via a Button or something like this which is positioned on the right side of every row, which makes those rows only hold the values but removes the VLOOKUP formula.
I could also copy the values of a row I want to freeze in the same row and click on the "Values only" command, which removes the formula but keeps the values but I just wanted to know if there is some sort of convinient function.
You can assign a simple macro to do so like:
Sub pastevalues()
On Error Resume Next
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I entered the error ignorance for cases when you paste without copying before.
You can add a short cut to the macro. This way if you are using the ctrl+v to paste make anew shortcut like ctrl+q to paste special values.
Related
The company creates an OLAP Cube Database for each of our clients. I keep up with many things using values in the cubes. Whenever a new client's cube is set up, I add a sheet to the workbook I use, and create a pivot table using that cube.
I want to checks the server for any cubes that may have been added.
I figured something like this would be the best way.
For Each Cube in Server.Cubes
MsgBox Cube.Name
Next Cube
I cannot find anything of the sort. I searched for an answer for a couple of days now. Any ways to parse through the server looking at the available cubes?
The SSAS Server has DMVs that you can query to determine the number of cubes on a server. Then you can use VBA to compare that to the number of rows in the table before. Follow these instructions to make the connection, or see below.
Create a new connection in Excel: In the Get External Data section choose From Other Sources -> SQL Server (NOT Analysis Services).
Enter connection information for any SQL Server to which you can connect (we'll change this info in a later step).
Pick any database and table to which you have access. Move through the wizard and choose Only save connection at the end.
Click Connections. Find your connection and click the Properties button.
On the Definition tab, update the connnection string to look like
Provider=MSOLAP.5;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=SSASDB;Data Source=MyServer\MyInstance;MDX Compatibility=1;Safety Options=2;MDX Missing Member Mode=Error
Change the Command Type to Default
Change the command text to the following:
SELECT
[CATALOG_NAME] AS SSAS_Database_Name,
[CUBE_NAME] AS Cube_or_Perspective_Name,
[CUBE_CAPTION] AS Cube_or_Perspective_Caption,
[CUBE_TYPE] AS Cube_Type,
[BASE_CUBE_NAME] AS Base_Cube
FROM
$SYSTEM.MDSCHEMA_CUBES
WHERE
CUBE_SOURCE=1
AND
[BASE_CUBE_NAME] < ''
Click OK and then click Close.
Click Existing Connections. Choose your connection.
Choose Table on the Import Data Window. Choose to Put your table on a new worksheet.
Your table should be in columns A through E. In cell G2 put Prior Row Count:
In cell G3 put Current Row Count:
In cell H2 put 0.
In cell H3, enter the following formula:
=COUNTA(Table_ExternalData_1[SSAS_Database_Name])
Write a macro that copies the value from cell H3 to H2 and then refreshes the data connection for the table. Mine looks like this:
Sub UpdateCubeCount()
Range("H3").Select
Selection.Copy
Range("H2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B2").Select
Application.CutCopyMode = False
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
End Sub
As a bonus, add conditional formatting to cell H3. Format it to have pink background and red text for the rule Cell Value > $H$2.
You end up with something that looks like this:
Update: If you are looking for the SSAS databases rather than the cubes themselves, you can use this query instead of the one in step 7:
SELECT [catalog_name] AS SSAS_Database_Name, [date_modified]
FROM $system.DBSCHEMA_CATALOGS
This would be useful if you can assume you only have one cube per database, which is fairly common.
I'm a complete novice when it comes to Excel, I've Googled it and it's come up with some responses that I don't understand in the slightest. Most of which are things I need to do in Visual Basic?
Essentially what I want is to set up several tabs for individual users, that generate from the main tab. All of which are set up already.
So IF Row R on Main Sheet has NO (Persons Initials)
Copy this row to the Nick tab (There will be 20+ rows for each user, not sure if that changes anything)
Any help would be incredible and massively appreciated!
Thanks,
Nick
You can probably get a start by recording a macro. Here's a link on how to do that: http://office.microsoft.com/en-us/excel-help/create-or-delete-a-macro-HP010342374.aspx#BMrecordmacro. After you click record, just start doing what you want done manually. That will show you some of the syntax. In this case, it will probably be easiest for you to format your summary data as a table, filter it by each person's initials and then copy the results to the individual tabs. Your recorded code is probably going to look something like this:
Sub CopyNO()
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:= _
"NO"
Range("Table1[#All]").Select
Selection.Copy
Sheets("NO").Select
Range("A2").Select
ActiveSheet.Paste
End Sub
To clean up the code you record, you'll want to try to change anything that says ActiveSheet to something like Sheets("SheetName") and, ideally, get rid of any .Select commands by instead using whatever is actually done with the selection. Here you might end up with something like:
Sub CopyNO()
Sheets("Summary").ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:= _
"NO"
Worksheets("Summary").Range("Table1").Copy _
Destination:=Worksheets("NO").Range("A5")
End Sub
I have got this code:
Worksheets("SOURCE_DATA_HIDDEN").Activate
Sheets("SOURCE_DATA_HIDDEN").Select
Columns("B").Copy
Sheets("RESOURCE_DEMAND").Select
Columns("C").Select
ActiveSheet.Paste
I use it to copy and paste a column from one sheet to another. The code used to work last time i checked and it somehow broke today.
It comes up with the following error:
Run time error 1004: That command cannot be used on multiple selections.
I really cant figure out what is going on. I haven't made any amendments to the code.
try to clear the clipboard Application.CutCopyMode = False
You can simplify that a lot more. If its just the values you are wanting too, change to PasteSpecial. Try this:
ThisWorkbook.Sheets("SOURCE_DATA_HIDDEN").Columns("B").Copy
ThisWorkbook.Sheets("RESOURCE_DEMAND").Range("C1").PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
Eliminates all the selecting and activating, which is generally a habit you dont want to keep!
I'm having a problem with VB PasteSpecial.
This code works perfectly in Excel VB (given that you have selected cells with data)
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
However, I'm using a third-party software (QlikView) that I extract the data from, which is then supposed to be copied into the Excel document. There is no problem with the normal paste but it MUST be transposed.
Obviously, since I dont have any content in the workbook to copy, I don't use
Selection.Copy
But because I don't copy anything from the document first (even though there are table data in the copy memory), this call returns bad argument exception (this also happens if I copy cells in that VERY workbook first and then just call the macro for transposing it).
Runtime error '1004' returned. PasteSpecial method of Range class failed.
Yes, I can paste it into the document, then cut it from the area, move it to the correct place and transpose it, but that is bad coding.
Have any of you experienced this and got a way to get this working ?
You will have to use the method as you mentioned above. You can also try this
Range("A1").Select
ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False
Application.CutCopyMode = False
But you will have to copy it again and transpose it. Other wise there is no direct way you can transpose it.
The reason that you cannot use PasteSpecial to transpose the data is due to the format of the data as it resides in the clipboard after you copy it from QlikView.
When you copy data from a QlikView table (which I assume you are copying from), it copies it to the clipboard in three formats: HTML, Unicode and standard (code-paged) text:
Comparing this with Excel's clipboard formats:
As you can see, when copying data in Excel, it stores the data in the clipboard in its own format and as such knows how to transpose the cells if required. For QlikView, the clipboard just contains plain text, therefore Excel does not know how to transpose this and as a result the PasteSpecial call fails.
If you are copying from a table in QlikView to Excel, I would recommend performing the transposition already in QlikView if you can by using a "Pivot Table" chart in QlikView (as you can drag the columns and rows around how you wish). Otherwise you will have to use Siddharth's code and transpose it once it's in Excel.
I've built a web app which has a paste button for populating a table. The data is originally copied from an Excel spreadsheet and pasted onto my form.
The problem is that I'm only seeing the displayed data, not the underlying values. For example, if the cell's value is 12.223 and the cell's format is only showing 12.2, 12.2 goes on to the clipboard.
Am I missing a trick here? Does anyone know how to pull the full data from the clipboard?
Edit: It appears that Excel makes 25 different formats available on the clipboard, including "XML Spreadsheet" which looks like it contains the actual information I need. However, it appears that only the Text version is available inside the browser. Is there an ActiveX control or something similar that I can use to grab this data?
The only way I can see to do it is to knock up some VBA code that makes use of the Windows Forms Object Library.
I have found a code example that makes use of the clipboard
http://www.dailydoseofexcel.com/archives/2004/12/02/putting-text-into-the-windows-clipboard/
By default this will just copy the visible text of the cell. To get it to output the actual value you'll need to change
cell.Text
to
cell.Value
Although this will probably mess up any dates if you have them.
EDIT:
Actually the dates seem to copy ok
After you've copied the cell, right-click and choose Paste-Special, then choose the Values option under Paste. This will paste the full value.
Given that you can't modify the excel spreadsheet it looks like you are stuck. The issue is that windows clipboard doesn't recognize the browser as being able to accept anything but plain text from the paste. Because of this it pastes it in as a plain text table which basically is just the visual representation of the data that excel presents to you.
If you built an ActiveX component for the page that could except spreadsheet data then the excel paste should work I think. A pure browser javascript implementation won't do what you need though.
Provided that you are happy using an extra sheet to contain the data formatted to copy you could also do the following
Sub CopyPasteSpecialCopy()
'Clear out temp destination
Sheets("CopyPasteSheet").Select
Cells.Select
Selection.ClearContents
'Copy data
Sheets("DataSheet").Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
'Paste data
Sheets("CopyPasteSheet").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells.Select
Application.CutCopyMode = False
'Put it onto the clipboard
Selection.Copy
End Sub
Although I can't see an option for pasting XML only values.
Again this Macro could be attached to the Ctrl + C key combination.