hansgrandia
Board Regular
- Joined
- Jan 10, 2015
- Messages
- 53
Hello,
I'm trying to embed an If function in VBA code but get stuck with several elements of the piece code (functions / brackets etc). The correct code for cell I2 would be =IF(H2=H1;WORKDAY(I1;1);F2)
Could someone help me to build this specific line of the code? Appreciated! Hans Grandia (Netherlands)
In below standing complete code
I'm trying to embed an If function in VBA code but get stuck with several elements of the piece code (functions / brackets etc). The correct code for cell I2 would be =IF(H2=H1;WORKDAY(I1;1);F2)
Could someone help me to build this specific line of the code? Appreciated! Hans Grandia (Netherlands)
For i = 2 To LastRow
Cells(i, 9) = IIf(ActiveCell= ActiveCell(-1,0)...
Next i
In below standing complete code
VBA Code:
Sub Add_Business_days()
Dim String1 As String
Dim String2 As String
Dim full_string As String
Application.ScreenUpdating = False
'Activeer sheet
Worksheets("AFAS_2").Activate
'insert column for calculation working days
Columns("H").Insert
Range("H1").Value = "Unique value"
'Determine Last_Row
With ActiveSheet
LastRow = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
End With
'Formula for Concatenate
For i = 2 To LastRow
String1 = Cells(i, 2).Value
String2 = Cells(i, 7).Value
Cells(i, 8) = String1 & String2
Next i
'Add correct date in new column
Columns("I").Insert
Range("I1").Value = "Date"
For i = 2 To LastRow
Cells(i, 9) = IIf(ActiveCell= ActiveCell(-1,0)...
Next i
Application.ScreenUpdating = True
End Sub