• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help!

Hi! Could anyone help me with this problem?


I´m trying to run a code, but I don´t know why when I press F8 to check each step of the code lines, it´s jumping the For Next loop step. I´ll write the code here, and if you see any mistake, please tell me, because I can´t!


Ps: The idea of the code is a matrix multiplication... It´s a 25x25 matrix (range g0) x 25x1 matrix (range y). It´s not the computation in fact, I just want it to show me how the multiplication would look like.

[pre]
Code:
Sub multmatriz()

Dim wg0 As Worksheet
Dim wy As Worksheet
Dim wg0y As Worksheet

Dim g0 As Range
Dim y As Range

Dim a As Long
Dim b As Long

Set wg0 = Worksheets("g0")
Set wy = Worksheets("matriz y")
Set wg0y = Worksheets("g0y")

Set g0 = wg0.Range("g0")
Set y = wy.Range("y")

a = 1
b = 1

For a = 1 To a = 25

For b = 1 To b = 25
wg0y.Cells(a, b) = g0.Cells(a, b).Value & "*" & y.Cells(b, 1)
Next

Next

End Sub
[/pre]

Thanks!
 
Change

[pre]
Code:
For a = 1 To a = 25
For b = 1 To b = 25
wg0y.Cells(a, b) = g0.Cells(a, b).Value & "*" & y.Cells(b, 1)
Next
Next

to

For a = 1 To 25
For b = 1 To 25
wg0y.Cells(a, b) = g0.Cells(a, b).Value & "*" & y.Cells(b, 1)
Next
Next
[/pre]
 
Also, there's no need for these 2 lines:

[pre]
Code:
a = 1
b = 1
[/pre]
Since your For..Next loops determine the start/stop points.
 
Now I'd like also to make the loop only if the value in g0.Cells(a, b).Value is different of zero. If its zero, then do nothing... how it would be?

[pre]
Code:
For a = 1 To 25

For b = 1 To 25
If g0.Cells(a, b).Value <> 0 Then
wg0y.Cells(a, b) = g0.Cells(a, b).Value & "*" & y.Cells(b, 1) & "+"
Else (jump to the next b... how can i say this???)
Next

Next
[/pre]
 
Hi, irisqueiroz!

I edited your code embedding it within backticks to increase readability.

If I didn't understood wrongly your question, replace entire "Else..." line by an "End If" and give it a try.

Regards!
 
Hi, irisqueiroz!

Glad you solved it. Thanks for your feedback and welcome back whenever needed or wanted.

Regards!
 
Can you help me with another thing?


Here what i'm trying to do is, if the cell A2 is not empty, then ill go to the last value in the row A, then press F2 (to edit the cell), and delete the last caracter in this cell. Else, if A2 is empty, I press F2 in A1 and delete the last caracter.


If Range("A1").Offset(0, 1) <> 0 Then

Range("A1").Select

Selection.End(xlToRight).Select

ActiveCell.Formula = "=left(activeCell.value,len(activecell.value)-1)" <- NOT WORKING

Else

Range("A1").Select

ActiveCell.Formula = "=left(ActiveCell.value,len(ActiveCell.value)-1)"

End If
 
Good day irisqueiroz


As SirJB7 has said if you have a different question then post as a fresh question on the board, if you just add to an existing post many board members will think it is related to the original and not look.


If you just put "Help" in the title bar it says nothing, members of the board have different Excel skills so would be looking for a title that says more to help them decide as to whether or not look, opening up post that do not relate to your Excel knowledge is a bit annoying
 
@b(ut)ob(ut)hc

Hi!

Good afternoon, old dog.

You're absolutely right, I entered this topic in the belief that I was going to find links to download an album of The Beatles.

I feel so sad for haven't found them that I'm going for a Carlsberg. Would you join me?

Regards!
 
Good evening SirJB7


To share a Carlsberg or two with your good self would be a pleasure, to sit back and listen to a Beatles album while discussing what to do with Montrey :)
 
@b(ut)ob(ut)hc

Hi!

So then welcome...

And about Montrey... I was wondering if perhaps you had the phone number or the electronic code of Bruce, I think that it's our only chance to help and save ourselves and the world and the galaxy too.

Yes, Bruce, the guy at The Jackal... you know...

I tried to contact Bodie and Doyle but George Cowley told me that Montrey was far beyond their scope and skills...

Regards!
 
Old friend, we could throw caution to the wind and go for the real thing.....Carlos the Jackal......but compassion say that it may be to much, even for Montrey.......but then again....
 
@b(ut)ob(ut)hc

Hi!

If you think so... I accept.

Let's change Carlos by... let me see... Austin Powers's Scott Evil will be Ok?

Regards!
 
Back
Top