-
Solved: VBA Copy and Paste Specific Cells Based On Another Cells Value
Hi, I wonder whether someone may be able to help me please.
I've put together the following code which, carries out the following procedure:
- Starting at row 7 on the "Input" sheet, check to see if there is a value in column B.
- If present, then search for the value "P" in column I and "I" in column L.
- If these criteria are met, copy the value in column J and paste into column B on the "In Flights Project" page.
[vba]
Option Explicit
Sub InFlightProjects()
Dim LR As Long, i As Long
Sheets("In Flight Projects").Range("B7:B1307").Cells.ClearContents
With Sheets("Input")
LR = .Range("B" & Rows.Count).End(xlUp).Row
For i = 7 To LR
With .Range("J" & i)
If .Offset(, -1).Value = "P" And .Offset(, 2) = "I" Then Sheets("In Flight Projects").Cells(Application.Max(Sheets("In Flight Projects").Cells(Rows.Count, "B").End(xlUp).Row + 1, 7), "B").Value = .Value
End With
Next i
End With
Columns("A:M").EntireColumn.AutoFit
End Sub
[/vba]
The code works fine but I'm having a little difficulty in exanding the copy and paste ranges.
What I would like to do is instead of just copying the value in column J, I'd like to copy the values in columns J, K and O, and paste these into the columns B,C and D respectively, whilst maintainig the rest of the functionality.
I just wondered whether someone could possibly look at this please and offer soem guidance on how I may be able to achieve this.
Many thanks and kind regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules