CheckEmoji Community · the emoji forum
🏠 Home 🆕 What's new ❓ Unanswered 🔥 Popular 📡 RSS Members 👥 0 online log in · register
Home › Jesse Ortiz6 › Posts

Posts by Jesse Ortiz6

5 posts shown.

electricdriver93 said:saved my skin.😁
Don't mention it.

😵😵 Sorry... thanks for saving me there.😁
electricdriver93 said:just swap out that first condition for this one:

If Cells(b, 1).Value Mod 2 = 0 And Cells(b, 1).Value <> 0 Then

Right, so you just need to update the cell reference arguments
like this:

Sub Macro1()

Dim a, b, c
a = Worksheets(1).Rows(1).Cells.SpecialCells(xlCellTypeConstants).Count
c = 1
For b = 1 To a
If Cells(1, b).Value Mod 2 = 0 And Cells(1, b).Value <> 0 Then
Cells(2, c).Value = Cells(1, b).Value
c = c + 1
End If
Next b

End Sub

Thanks, legend... you really saved my skin here...😁😁😁😁
electricdriver93 said:this gets the job done:

Sub Macro1()

Dim a, b, c
a = Worksheets(1).Columns(1).Cells.SpecialCells(xlCellTypeConstants).Count
c = 1
For b = 1 To a
If Value mod 2 = 0 Then Cells(b, 1).Value = Cells(b, 1).Value
Cells(c, 2).Value = Cells(b, 1).Value
c = c + 1
End If
Next b

End Sub

It worked 🙂perfectly.

The error was actually just a syntax issue—I had a space between (xlCell and TypeConstants) that shouldn't have been there.

Thank you so much!!!!!!

My only remaining headache is that when I input a zero, the code treats it as an even number... is there a way to add a specific condition to prevent that??
Also, how would one define this to work on rows instead of columns??
electricdriver93 said:this should get the job done:

Sub Macro1()

Dim a, b, c
a = Worksheets(1).Columns(1).Cells.SpecialCells(xlCell TypeConstants).Count
c = 1
For b = 1 To a
If Value mod 2 = 0 Then Cells
Cells(c, 2).Value = Cells(b, 1).Value
c = c + 1
End If
Next b

End Sub

Best regards!!
Unfortunately, I can't get this to run... it keeps throwing a syntax error at me.

And it highlights this specific line in red:
a = Worksheets(1).Columns(1).Cells.SpecialCells(xlCell TypeConstants).Count
Greetings, everyone.

I am reaching out because I could use some assistance with a specific task... I suspect this ought to be handled within Visual Basic, though I cannot say for certain myself.

"Write a program that identifies all even numbers located in the first column of a spreadsheet. The program should then display these identified numbers, one after another, in the second column."

Thank you in advance, and best regards.