Place formulas in every other column?

Madeiracakez

New Member
Joined
Aug 8, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Trying to clean up a spreadsheet for work, we have thousands of tasks, each with dates that correspondences came in and went out, with the NETWORKDAYS formula between each, to show days between these exchanges. Is there a quick way of placing this formula over every other column for the entire workbook so that there are still columns in between for the dates to be filled?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Welcome to the Board!

Probably the best way is to use VBA. We could help you come up with code, but obviously need a lot more detail from you (i.e. what cells we are talking about, what formulas to insert, etc).
 
Upvote 0
Thank you, I definitely fudged my excel skills on my CV and am regretting it now! the in date is in cell W2, then the formula is in X2, the out date is then in Y2, this pattern continues all the way to the right and down throughout the spreadsheet. So I need the formula to be between the in and the out date and to continue this way, the whole sheet has been a mess since I started and so there are more than 1000 rows of different tasks all with different in and out dates. I don't think a variation on NETWORKDAYS to exclude weekends is necessary.
 

Attachments

  • Screenshot (2).png
    Screenshot (2).png
    40.9 KB · Views: 4
Upvote 0
What exactly does your formula look like?

Are the formulas in column X and Z the same?
If not, please post each formula.

What is the last column you need populated?
 
Upvote 0
The formulas in X and Y are the same,
=IF(Y2>0,NETWORKDAYS(W2,Y2,2),0)
Obviously as it carries over, it changes reference point.
 
Upvote 0
The formulas in X and Y are the same,
=IF(Y2>0,NETWORKDAYS(W2,Y2,2),0)
Obviously as it carries over, it changes reference point.
Hmmm... that does not sound right to me.
Did you mean to say X and Z, not Z and Y?

And based on your example, the formulas in X and Z cannot be the same thing, as they are returning different values!
 
Upvote 0
I did mean X and Z, sorry,
=IF(AA2>0,NETWORKDAYS(Y2,AA2,2),0)
this is in Z
 
Upvote 0
Try this:
VBA Code:
Sub MyFormulaMacro()

    Dim lr As Long
    Dim c As Long
    
    Application.ScreenUpdating = False
    
'   Find last row with data in column W
    lr = Cells(Rows.Count, "W").End(xlUp).Row
    
'   Populate every other column from X to DP
    For c = 24 To 120 Step 2
'       Populate all rows in column with formula
        Range(Cells(2, c), Cells(lr, c)).FormulaR1C1 = "=IF(RC[1]>0,NETWORKDAYS(RC[-1],RC[1],2),0)"
    Next c
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 1
Solution

Forum statistics

Threads
1,215,461
Messages
6,124,954
Members
449,198
Latest member
MhammadishaqKhan

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