Yamasaki450
Board Regular
- Joined
- Oct 22, 2021
- Messages
- 71
- Office Version
- 2021
- Platform
- Windows
Hi guys.
Does anyone know how to select cells diagonally without holding down ctrl and selecting cells individually?
I found this two codes on net they both work but cells are selected in right and down direction...
I want to select cells in up and right direction (see screenshot)
Does anyone know how to adjust any of this codes so the cells are selected in up and right direction?
Or maybe there is another option?
First one
Sub selectDiag()
'UpdatebyExtendoffice20171128
Dim I As Long
Dim xCount As Long
Dim xRg As Range
On Error Resume Next
Set xRg = ActiveCell
If xRg Is Nothing Then Exit Sub
xCount = Val(InputBox("How many cells do you want to select diagonally?", "KuTools For Excel"))
If xCount = 0 Then Exit Sub
For I = 1 To (xCount - 1)
Set xRg = Union(xRg, ActiveCell.Offset(I, I))
Next I
xRg.Select
End Sub
Second one (post 5)
Sub selectDiag()
Dim i As Integer, j As Integer
Dim myRng As Range
Set myRng = ActiveCell
j = Val(InputBox("How many cells do you want to select diagonally?", "Diagonal Cell Selection"))
For i = 1 To j
Set myRng = Union(myRng, ActiveCell.Offset(i, i))
myRng.Select
Next i
End Sub
Thanks.
Does anyone know how to select cells diagonally without holding down ctrl and selecting cells individually?
I found this two codes on net they both work but cells are selected in right and down direction...
I want to select cells in up and right direction (see screenshot)
Does anyone know how to adjust any of this codes so the cells are selected in up and right direction?
Or maybe there is another option?
First one
How to select and highlight diagonal cells in Excel?
ExtendOffice provides a comprehensive range of professional software solutions, enhancing productivity and efficiency for businesses worldwide.
www.extendoffice.com
Sub selectDiag()
'UpdatebyExtendoffice20171128
Dim I As Long
Dim xCount As Long
Dim xRg As Range
On Error Resume Next
Set xRg = ActiveCell
If xRg Is Nothing Then Exit Sub
xCount = Val(InputBox("How many cells do you want to select diagonally?", "KuTools For Excel"))
If xCount = 0 Then Exit Sub
For I = 1 To (xCount - 1)
Set xRg = Union(xRg, ActiveCell.Offset(I, I))
Next I
xRg.Select
End Sub
Second one (post 5)
Selecting/ highlighting a diagonal range?!?
Is there a way to select a diagonal range in Excel? Has anyone created a macro or code to make this work? Some ideas on how to get started would be a huge help and I'd work on it myself - I'm a statistician not a coder. I used search on here and found nothing. Thanks this would come in handy on...
www.excelforum.com
Sub selectDiag()
Dim i As Integer, j As Integer
Dim myRng As Range
Set myRng = ActiveCell
j = Val(InputBox("How many cells do you want to select diagonally?", "Diagonal Cell Selection"))
For i = 1 To j
Set myRng = Union(myRng, ActiveCell.Offset(i, i))
myRng.Select
Next i
End Sub
Thanks.