Need help with an assignment involving Macros.

Oppogo

New Member
Joined
Sep 24, 2015
Messages
6
Hello!
I was assigned to come up with certain numbers in 2 spaces (X and DX) in order to satisfy 2 different assignments and to be honest it has me quite stumped.
I need to:
  • find 2 numbers which would generate entirely negative table
  • find 2 numbers which would generate a table with every pair element (collumns like D4, D6, D8...) to have a negative number in them and every odd column to have numbers of any value (either positive or negative)
I am finding it really difficult to come up with a solution to these and I was wondering if maybe someone here could be of any help. The macro looks like this :
Code:
Public Sub genSin()Dim i As Integer, k As Integer
Dim x As Single, dx As Single
Dim y(1 To 20) As Single, maxV As Single
Dim Idet As Integer
Cells(1, 2) = "      X"
Cells(1, 3) = "      DX"
x = Cells(2, 2)


dx = Cells(2, 3)
For i = 1 To 20 Step 1
y(i) = 10 * Sin(x)
x = x + dx
Next i
For k = 0 To 20 \ 4 - 1
For i = 1 To 4 Step 1
Cells(k + 5, i) = y(k * 4 + i)
Next i
Next k


STEP1:
i = 2
Do While (i <= 21)
If (y(i) > 0) Then
  maxV = y(i)
  Idet = i
  GoTo Step2
Else:
  i = i + 2
End If
Loop
MsgBox (" There are no positive numbers in the array.")
GoTo ENDING
Step2:
i = 2
Do While (i <= 21)
If (y(i) > 0) And (y(i) < maxV) Then
  maxV = y(i)
  Idet = i
  i = i + 2
 Else
 i = i + 2
 End If
Loop
MsgBox ("Outcome  Idet= " & Idet & "    maxv= " & maxV)
Cells(1, 5) = "  Idet"
Cells(1, 6) = "  maxV"
Cells(2, 5) = Idet
Cells(2, 6) = maxV
ENDING:
End Sub

The table looks like this

CFiIYnG.png


I would greatly appreciate any help you guys might be able to provide. Either the answers or simple guidlines to follow in order to achieve the desired numbers.
Thanks in advance!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,216,156
Messages
6,129,188
Members
449,492
Latest member
steveg127

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top