VBA row insert coding assistance

Wolfe

New Member
Joined
Jan 17, 2018
Messages
2
Hello. I am new to VBA coding and have never worked with creating a Macro prior to this. Any assistance would be greatly appreciated.

I have a Excel sheet that is named Flight Log Tracker and I would like the sheet to automatically insert a row when the value in AU column is "Y". The inserted row has a range of A:BD. Also, I need the new inserted cell in column AO to contain the following formula; =ROUNDUP((BC31-INT(BC31))*24,1). This example is for cell AO31.

Below is my attempt at the code.

Dim I As Long
Dim LASTROW As Long

LASTROW = Cell(Row.Count,1).End(xlUp).Row

For i=LASTROW To 1 Step -1
If InStr(Range("AU" & i).Value = "Y" Then
Range("A:BD" & i).EntireRow.Insert
Shift:xlDown
Range("AO" & i).Value = "Y"
Range("AO" & i).Offest (0,1).Formula = "ROUNDUP (("BC" & i)-INT("BC" & i))
End If

Next I

End Sub


Any assistance would be grateful. Thank you for your time in helping me with my problem.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi & welcome to the board
Try this
Code:
Sub chk()
Dim I As Long
Dim LASTROW As Long

LASTROW = cell(Rows.Count, 1).End(xlUp).Row

For I = LASTROW To 1 Step -1
   If Range("AU" & I).Value = "Y" Then
   Range("A" & I).EntireRow.Insert
   Range("AO" & I).Value = "Y"
   Range("AO" & I).Offest(1).Formula = "=ROUNDUP((rc55-INT(rc55))*24,1)"
End If

Next I

End Sub
 
Upvote 0
Thank you for the quick reply. I am getting a compile error when I run the code in my Excel 2013. The system does not like the "cell" portion of the fourth line of the code.
 
Upvote 0
That should be cells plural
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

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