Football lines

speedracer7278

New Member
Joined
Aug 24, 2007
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I would like: If value in power cell are negative to convert them to positive and move up to Visiting team? Example move and change Atlanta Power 3 from -2 into 2 and move up to Carolina cell just above. Same for entire worksheet single function. Thanks for having this site. I have been off excel for 16 years and things have changed.
Casino linePower 1Power2Power 3
451​
Detroit
452​
Kansas City
4​
11.5​
7.5​
5​
453​
Carolina
454​
Atlanta
3.5​
9​
2.5​
-2​
455​
Houston
456​
Baltimore
10​
10​
7.5​
11​
457​
Cincinnati
458​
Cleveland
-2​
6​
1​
-7​
459​
Jacksonville
460​
Indianapolis
-5​
3​
0​
-13​
461​
Tampa Bay
462​
Minnesota
6​
3​
4.5​
7.5​
463​
Tennessee
464​
New Orleans
3.5​
7.5​
6.5​
8​
 
Last edited by a moderator:

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.
Welcome to the Board!

So is this what you are looking for (updated values in red)?

1694424551125.png


Here is VBA code that will do that:
VBA Code:
Sub MyMacro()

    Dim lr As Long
    Dim r As Long
    Dim c As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows and columns
    For r = 2 To lr
        For c = 3 To 6
'           If value is less than zero, copy postitive value to line above
            If Cells(r, c).Value < 0 Then
                Cells(r - 1, c).Value = 0 - Cells(r, c).Value
'               Uncomment following line if you want to remove negative
                'Cells(r, c).ClearContents
            End If
        Next c
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Solution
I anticipated that. Did you see this part of my code?
VBA Code:
'               Uncomment following line if you want to remove negative
                'Cells(r, c).ClearContents
Remove the single quote mark so it looks like this:
VBA Code:
'               Uncomment following line if you want to remove negative
                Cells(r, c).ClearContents
and it should do what you want.
 
Upvote 0
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,224,737
Messages
6,180,653
Members
452,992
Latest member
TokugawaIesuma

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