I have an object of QTableWidget. Whenever, I click on a cell of the table, it becomes blue. How can I make a cell blue, say the cell located at row 1 and column 1, programmatically.
You have to use the selectionModel:
row = 1
column = 1
index = table_widget.model().index(row, column)
table_widget.selectionModel().select(
index, QItemSelectionModel.Select | ItemSelectionModel.Current
)
Related
with the command I color all columns starting from the first row,
Rows(ActiveCell.Row).Parent.Columns("A:I").Interior.ColorIndex = 42
but I would need to color the columns from A to I starting from row 3, how can I set the command, thanks
Columns means entire column so you need to use Range, to color only a range. Also it is unclear what you want to do with Rows(ActiveCell.Row).Parent because this is the same as ActiveSheet.
ActiveSheet.Range("A3:I1000").Interior.ColorIndex = 42
Here 3 is the first row and 1000 is the last row that gets colored in the columns A to I.
Have to create a column next to existing column. my present table is like this
and result needed is like this. Each date value is getting repeated 3 times and getting incremented by 1
Pick any cell and enter:
=DATE(2018,8,21+ROUNDUP(ROWS($1:1)/3,0))
and copy downward.
Here our start cell is one cell to the left of the 21.
Manually type in the first 3 into A1:A3 (or rows 1 to 3) in A4 (or row 4) reference A1 (row 1) and add 1 to it. Then drag the formula down.
The formula should look like =A1+1
I need some help here if someone can provide me a code for this.
Scenario:
cell A is a drop down list
column B has a static value
cell C is where they input the value
cell D is where the value of cell c stored
so if cell A = value in column B, the value of cell C should be copied and saved to cell D, because cell A is a dropdown list, if I change the cell A to another value, cell c should reset to "blank", but the value of cell D should remain to where cell A = cell B.
I have this code inputed in cell D, but when I change the value of cell A, the value of cell D also disappear which it should remain where cell a = cell b
=vlookup(A2,Sheet1!B2:C5,2,FALSE)
I'm new to excel vba so any help will be much appreciated.
thanks,
Overly simplified, but here's a solution ...
First, here is a screenshot of how I set up the data ...
The data in column A uses a drop down list. Values that may or may not be the same are entered into column B. Column C are user entries and Column D gets those upon recalculation.
Here is the code behind the Recalculate button ...
Option Explicit
Option Base 1
Public Sub Recalculate()
Dim iLoop As Integer
For iLoop = 2 To 4
If Sheets("Sheet1").Cells(iLoop, 1) = Sheets("Sheet1").Cells(iLoop, 2) Then
Sheets("Sheet1").Cells(iLoop, 4) = Sheets("Sheet1").Cells(iLoop, 3)
Else
Sheets("Sheet1").Cells(iLoop, 3) = ""
End If
Next iLoop
End Sub
I didn't do anything to handle adding rows, etc. Just blindly calculating as you requested.
I changed the value in A3 and here is a screen shot of the result.
I need some help.
What I need is a code for colorid the Grid in Excel in this way:
find the first cell with value ( 1 )
find the last cell with value ( 2 )
range (1:2)
Color the grid black
My code by now:
'Color the columns A to K and ALL the rows below, no matter if they have a value or not.
xlWorkSheet.Range(xlWorkSheet.Cells(1, 1), xlWorkSheet.Cells(xlWorkSheet.Rows.Count, 11)).Borders.ColorIndex = 0
I need to change the color of not-empty rows .
THX
Find the first cell :
You should active the first cell (A1) and use IsEmpty function.
Then you loop in the same column until you find a cell containing a value.
By the way, you need to keep the number of this row for the second point.
Find the last cell :
You have to exit your loop when it finds a new empty row. Then you'll get the range of cells using the number of first and last row.
You can check the MSDN - "Empty Cells" to get more details.
I'm trying to write some code for a button click to perform a VLOOKUP.
Sheet1 = Payment Form, Sheet2 = Global, Sheet3 = Details
Button will be on Sheet "Payment Form".
This would be the code for Cells in Global Sheet,
O1 = =VLOOKUP(BA,Details!A:H,8,0)
P1 = =VLOOKUP(BA,Details!A:H,6,0)
Q1 =VLOOKUP(BA,Details!A:H,5,0)
I need this to loop through all rows as the amount can change each month, if a match is found the perform the VlookUp, is no match is found, the delete the row from the Details Sheet.
For Example: Global, Cell B1 = 27801. In Details match found, then do the above codes from Columns O, P & Q.
Global, B2 = 27802. In Details no matching record found, row deleted. Continue to row 3 & 4 ......
what I suggest is you put all the value in table will be more efficient (not simply enter in the excel cell), you need create the table by INSERT ->Table. It will look like this :
Do this also for the Details :
Back to global worksheet, just need enter 1 row of formula, the rest of the rows in the same column will have the same formula "style"
Column O :=VLOOKUP([Column BA],Table2[[#All],[Column1]:[Column8]],8,FALSE)
Column P :=VLOOKUP([Column BA],Details!A:H,6,FALSE)
Column Q :=VLOOKUP([Column BA],Details!A:H,5,FALSE)
To remove the unwanted row, just filter out the blanks value in that columns will do.