montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 986
- Office Version
- 2010
- Platform
- Windows
Hello everyone
After searching here, I found some post here about palindromic algorithm, but those do not fit in the idea I am looking for.
The close code to the idea I am working on, is this code:
But the only thing I get from here is just to select some cells on diagonal. Then I write a low-level code as illustration on what I am trying to accomplish
So this is my try:
for illustration (not able to download xl2bb, sorry) this is what a good looping code will generate
the range B2:G2 is compare against the diagonal B3,C4,D5,E6,F7,G8 and if any value is equal then on the range I:N will show the results if any match equal 1 else 0
what I expect is go to the LastRow in myArray.
Please any possible help?
Thank you for reading this post.
After searching here, I found some post here about palindromic algorithm, but those do not fit in the idea I am looking for.
The close code to the idea I am working on, is this code:
VBA Code:
Sub SelectDiagonal()
Dim myRange As Range
Set myRange = ActiveSheet.Range("A4").CurrentRegion
Dim a As Long, b As Long, c As Long, d As Long, i As Long
a = myRange.Row()
b = myRange.Column()
c = myRange.Rows.Count
d = myRange.Columns.Count
Dim Rng As Range
Set Rng = Cells(a + c - 1, b)
For i = 1 To c - 1
Set Rng = Union(Rng, Cells(a + c - 1 - i, b + i))
Next
Rng.Select
End Sub
But the only thing I get from here is just to select some cells on diagonal. Then I write a low-level code as illustration on what I am trying to accomplish
So this is my try:
VBA Code:
Option Explicit
Sub Palindro_mic()
Dim a As Integer, b As Integer, c As Integer, d As Integer, e As Integer
Dim f As Integer, g As Integer, h As Integer, i As Integer, j As Integer, k As Integer, L As Integer
a = Range("B3").Value
b = Range("B2").Value
If a = b Then
Range("I2").Value = 1
Else
Range("I2").Value = 0
End If
c = Range("C4").Value
d = Range("C2").Value
If c = d Then
Range("J2").Value = 1
Else
Range("J2").Value = 0
End If
e = Range("D5").Value
f = Range("D2").Value
If e = f Then
Range("K2").Value = 1
Else
Range("K2").Value = 0
End If
g = Range("E6").Value
h = Range("E2").Value
If g = h Then
Range("L2").Value = 1
Else
Range("L2").Value = 0
End If
i = Range("F7").Value
j = Range("F2").Value
If i = j Then
Range("M2").Value = 1
Else
Range("M2").Value = 0
End If
k = Range("G8").Value
L = Range("G2").Value
If k = L Then
Range("N2").Value = 1
Else
Range("N2").Value = 0
End If
End Sub
the range B2:G2 is compare against the diagonal B3,C4,D5,E6,F7,G8 and if any value is equal then on the range I:N will show the results if any match equal 1 else 0
what I expect is go to the LastRow in myArray.
Please any possible help?
Thank you for reading this post.