2

I have read articles that have led me to change the first line into a variable but I need the "n94" to be a variable as well. It will always be 7 lines up and on the N column. I have to re-edit this in the future to 6 lines up etc... Trying to concatenate memo notes and its taking way too long with the amount of data.

Range("B101").Select
Selection.Copy
Range("N94").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
Rows("95:101").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

Thank you for any help

2
  • Its not clear what you have, and what you want to do Commented Jan 30, 2014 at 9:19
  • I am trying to copy cell B101 and special paste as values to cell N94 then delete the rows 95-101. After that I want to select another cell in Column B and repeat the procedure. Commented Jan 30, 2014 at 9:21

1 Answer 1

1

It will always be 7 lines up and on the N column

Is this what you are trying?

Sub Sample()
    Dim ws As Worksheet
    Dim rng As Range

    '~~> Replace this with the actual sheet name
    Set ws = ThisWorkbook.Sheets("Sheet1")

    With ws
        Set rng = ActiveCell '<~~ From Comments below

        If (rng.Row - 7) < 1 Then
            MsgBox "Cannot Paste. Row Out of bounds"
            Exit Sub
        End If

        rng.Copy

        .Cells(rng.Row - 7, "N").PasteSpecial _
        Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

        '~~> Delete the rows. For example Rows("95:101")
        .Rows((rng.Row - 6) & ":" & rng.Row).Delete Shift:=xlUp
    End With
End Sub
Sign up to request clarification or add additional context in comments.

9 Comments

That is something like it. But I would like to click on the cell and let the macro run. If I have to change the section like B101 it would take longer than me manually doing it. If that could be a variable I would be most happy :) I have about 6000 rows left and I have been doing it manually.
Change .Range("B101") to ActiveCell :)
Almost there: I have Set ws = "ASM-Concatented Address w notes" and when I run it I get an input box to create a table and select my data cell. ~ Unsure what it means.
change Set ws = "ASM-Concatented Address w notes" to Set ws = ThisWorkbook.Sheets("ASM-Concatented Address w notes") I am assuming that you have a sheet with that name in your workbook.
Siddharth it is working awesome. Anyway that removing the 7 rows after the pasted cell. Like if the paste goes to n94 the rows 95 through 102 can be deleted.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.