This is what I currently have:
If Sheet6.Range("j8").Value <> 0 Then
Sheet6.Range("j8").Copy Sheet6.Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
End If
Sheet6.Range("J8").ClearContents
But the problem is that I only need to copy the values, not the entire format (I have tried with pastespecial xlpastevalues, but have had little success)..and the other problem that I have is that in order for this macro to work, I have to click on another cell (it can't be active)..but I need it to work while the cell is still active..Please help, thanks
Related
I'm trying to create a simple function on a LibreOffice Calc sheet.
I have a table of information where cells A1:K2 has headings (the cells in Row 2 are merged)
all the information runs from A3:K176
The sheet has various functions running on it already, all I need is one more function.
At first I wanted it to automate when i open, but then i thought running the BASIC macro off of a button might be better, so i can edit and then just hit the button once I'm done.
I have the button linked up to run the macro already, but now im stuck... I have tried many ways of writing the code, but it seems that i am just too green to figure it out.
the last time i ran Excel advanced functions i was in high school.
ok, enough talking...
All I need the macro to do is once I hit the button, I need it to check column K and any value > 1 it needs to take that whole row and copy it then go to a target sheet, clear any data on the target sheet. then copy that set of rows to the next open row in the target sheet. possibly even exporting the result to a .txt file as a bonus.
this is a start...
in future I would like to add another button that will do the same function to a array lower down and put that into a different sheet.
Option Compatible
Sub SWD_AwakeningsTrade
Dim i, LastRow
LastRow = Sheets("Card_List").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Awakenings For trade").range("A2:I500").clearContents
For i=2 to LastRow
If Sheets("Card_List").Cells(i,"K").Value = "(>1)" Then
Sheets("Card_List").Cells(i, "K").EntireRow.Copy
Destination:=Sheets("Awakenings For trade").Range("A" & Rows.Count.end(xlUp)
End if
next i
End Sub
The tests I am developing access the DataGrid cells the following way:
window.Get<ListView>(gridName).Rows.First().Cells.First()
Then clicking a cell with UIItem.Click() method works fine, unless the cell is bound to a null value. In such a case, I get an exception:
Failed to click on ListViewCell. AutomationId:, Name:, ControlType:text, FrameworkId:WPF, bounds empty
Which makes sense, as apparently, an AutomationElement related to that cell is a TextBlock of 0 boundaries.
Is there some possible workaround to click such a cell so the tests work?
What seems to be a good enough workaround is the following:
this.window.Mouse.Location = Point.Subtract(cellToClick.ClickablePoint, new Vector(12, 6));
this.window.Mouse.Click(this.window.Mouse.Location);
So I just set the mouse location using property TestStack.White.UIItems.Mouse so it is situated right above the cell, then click.
I have a powershell script in that script i am using datagridview.
My script is working fine. All looks ok to me.
My issue is i want to get the first column value of selected row. To fulfill this i need to add event (cell click/cell content click/cell mouse click). I am not able to figure it out. How to add event.
Can somebody please advise me on this?
$datagridview1_CellMouseClick = [System.Windows.Forms.DataGridViewCellEventHandler]{
write-host $_.RowIndex # This displays the row number selected
write-host $_.ColumnIndex # This displays the column number selected
write-host $datagridview1.Rows[$_.RowIndex].Cells[0].value # This would display the value of the first cell in the selected row
write-host $datagridview1.Rows[$_.RowIndex].Cells[$_.ColumnIndex].value # This would display the value of the cell selected
}
There are plenty of example availble for C# but not found anything for powershell.
Not a stupid question at all, but a little confusing. You say you want the first column value of the selected row, however based on the output you are looking for it seems you are more interested in the selected cell. I am answering with the assumption that the selection of the cell is what you are looking for.
There are many possible events to work with here. The differences between them are subtle so I will leave it to you to see if there is an event that would work better for your purpose. For my answer I will stick with the event you mentioned: CellMouseClick.
I start by creating the function that I want to execute when the click occurs.
function gridClick(){
$rowIndex = $myGrid.CurrentRow.Index
$columnIndex = $myGrid.CurrentCell.ColumnIndex
Write-Host $rowIndex
Write-Host $columnIndex
Write-Host $myGrid.Rows[$rowIndex].Cells[0].value
Write-Host $myGrid.Rows[$rowIndex].Cells[$columnIndex].value}
Please note that you will have to decide how your variables are scoped and how the function will interact with the datagrid. If you are declaring the datagrid at the script level then you should be able to just reference it by name inside the function. This function will do what you said, in the exact order listed in your question. Edit to taste.
You can add the click event, after declaring your datagrid, like this:
$myGrid.Add_CellMouseClick({gridClick})
Note that the name of the function we created is placed within the brackets.
A few important notes:
There are many events to work with. While testing this out I tried the selectionChanged, click, cellclick, cellmouseclick, enterrow, and other events. You may want to check these out for differences in behavior.
The output may be a little unusual in some cases. For example the CellMouseClick event seems to respond to clicks in the header. So if I click on the cell at row index 1 and column index 1 (second row second column) the script will display the contents appropriately. If I then click on the column heading for the first column, the script will write the same results again (which makes sense because the selected index has not changed) which may seem confusing at first glance.
Keep in mind that datagrids allow for multiple selections and I do not know how that might effect the output. That is up to you to figure out.
I have a uitable with 10 columns, which I'm populating from a db.
Now I want to know when the user choose a specific row. For example if the user chooses the 3rd record, I would like to get back the value 3, so then I could access the actual information to for example open that specific record from the path.
I found online that I would need findjobj.
I also think that the method should be implemented in here:
function uitable_CellSelectionCallback(hObject, eventdata, handles)
However I found a little information about how I should proceed.
Anyone had this problem or knows how to solve it?
When calling the CellSelectionCallback you can access the Indices property, which is a 2 x 1 array containing the row and column indices of the cell you have selected.
Therefore in your callback, use something like this:
row = eventdata.Indices(1)
col = eventdata.Indices(2)
and that should get you going.
In order to avoid callbacks, you can use app.UITable.Selection in the newer versions of MATLAB where app is your app object and UITable your uitable name
I am creating a uitable using GUIDE with 4 columns: 1st – Numeric, 2nd – Let Matlab choose,
3rd – Text, Editable, 4th – Logical, Editable.
When I run my GUI and try to mark the Logical checkbox I get this error: Warning: Table data is not editable at this location. Please click for more information.
I have tried to solve the problem and failed. Therefore, how can I fix it? I wish to check or uncheck them (the default selection should be checked).
Thanks.
Try this in the create function for your uitable:
set(yourUitableHandle, 'ColumnEditable', [0 1 1 1]);
If the problem persists, something in GUIDE is automatically changing that property for you. Likely on the Data section of property viewer for the uitable. Let me know if that doesn't fix it, and I'll give it another shot.