VBA Code Issue

superfb

Active Member
Joined
Oct 5, 2011
Messages
251
Office Version
  1. 2007
Platform
  1. Windows
Hi, i have a code where i have tried to adjust it to do the following:

1. At the bottom of column B (in this case row 84) to copy this row and insert it above.
2. I have a if Formula =IF(B81="Mar","Jun",IF(B81="Jun","Sep",IF(B81="Sep","Dec",IF(B81="Dec","Mar")))) - but this keeps referring to B81 rather than the one above it. I would like this VBA code to paste the value.
3. Subsequently then delete the row of data from C:R

The code i have is this which isnt working:

VBA Code:
Sub AddRowMonthTab6()

Range("C2").Select
With Range("C" & Rows.Count).End(xlUp)
      .Offset(-10, -2).Resize(, 22).Copy
      .Offset(-10, -2).Insert xlDown
       Application.CutCopyMode = False
       .Offset(-10, 0).Select
     ' Intersect(.EntireRow, Range("C:U")).ClearContents
   End With
   
With Range("C" & Rows.Count).End(xlUp)
.Offset(-10, -1).FormulaR1C1 = "=IF(R[-1]C=""Mar"",""Jun"",IF(R[-1]C=""Jun"",""Sep"",IF(R[-1]C=""Sep"",""Dec"",IF(R[-1]C=""Dec"",""Mar""))))"
.Value = .Value
'Intersect(.EntireRow, Range("D:U")).Clear
End With


With Range("C" & Rows.Count).End(xlUp)
Intersect(.EntireRow, Range("D:U")).Clear
 'End With
 
End Sub

The problem is:

1.Formula doesnt paste value
2.The data it deletes is from row 94

Ideally i would like to change the months in the row 87, 91, 93 and 94

e.g, row 91: When updated it should be December








Issue.JPG
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,214,891
Messages
6,122,101
Members
449,066
Latest member
Andyg666

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