+ Reply to Thread
Results 1 to 6 of 6

Error in Code - Pasting Values

Hybrid View

Guest Error in Code - Pasting Values 09-01-2005, 02:05 PM
Guest RE: Error in Code - Pasting... 09-01-2005, 03:05 PM
Guest RE: Error in Code - Pasting... 09-01-2005, 03:05 PM
Guest RE: Error in Code - Pasting... 09-01-2005, 03:05 PM
Guest RE: Error in Code - Pasting... 09-01-2005, 05:05 PM
Guest RE: Error in Code - Pasting... 09-01-2005, 05:05 PM
  1. #1
    Janet H
    Guest

    Error in Code - Pasting Values

    Here is my code - I'm getting an error at the **. I'm trying to paste the
    result of my formula as a value.

    Also, I don't like the RC cell references. I tried to change them manually
    but then the macro doesn't run.

    I don't do much visual basic. I record a macro and then TRY to edit it.

    Thanks for any help.

    ActiveSheet.Unprotect
    Range("A24").Select
    Selection.Copy
    Range("A25").Select
    ActiveSheet.Paste
    Range("C24:G24").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("C25").Select
    ActiveSheet.Paste
    Range("h25").Select
    ActiveCell = "0"
    Range("i25").Select
    ActiveCell = "0"
    Range("J24").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("M22").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False
    Range("N22").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=rc[-1]*0.2"
    Range("N22").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("J25").Select
    **Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    SkipBlanks _
    :=False, Transpose:=False
    ActiveSheet.Protect
    End Sub

  2. #2
    Jim Thomlinson
    Guest

    RE: Error in Code - Pasting Values

    Give this a try...

    ActiveSheet.Unprotect
    Range("A24").Copy Range("A25")
    Range("C24:G24").Copy Range("C25")
    Range("H25").Value = 0
    Range("I25").Value = 0
    Range("J24").Copy
    Range("M22").PasteSpecial Paste:=xlPasteValues
    Range("N22").Formula = "=M22*0.2"
    Range("N22").Copy
    Range("J25").PasteSpecial Paste:=xlPasteValues
    ActiveSheet.Protect

    --
    HTH...

    Jim Thomlinson


    "Janet H" wrote:

    > Here is my code - I'm getting an error at the **. I'm trying to paste the
    > result of my formula as a value.
    >
    > Also, I don't like the RC cell references. I tried to change them manually
    > but then the macro doesn't run.
    >
    > I don't do much visual basic. I record a macro and then TRY to edit it.
    >
    > Thanks for any help.
    >
    > ActiveSheet.Unprotect
    > Range("A24").Select
    > Selection.Copy
    > Range("A25").Select
    > ActiveSheet.Paste
    > Range("C24:G24").Select
    > Application.CutCopyMode = False
    > Selection.Copy
    > Range("C25").Select
    > ActiveSheet.Paste
    > Range("h25").Select
    > ActiveCell = "0"
    > Range("i25").Select
    > ActiveCell = "0"
    > Range("J24").Select
    > Application.CutCopyMode = False
    > Selection.Copy
    > Range("M22").Select
    > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    > Range("N22").Select
    > Application.CutCopyMode = False
    > ActiveCell.FormulaR1C1 = "=rc[-1]*0.2"
    > Range("N22").Select
    > Application.CutCopyMode = False
    > Selection.Copy
    > Range("J25").Select
    > **Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    > ActiveSheet.Protect
    > End Sub


  3. #3
    Janet H
    Guest

    RE: Error in Code - Pasting Values

    Wow. That's like speaking English. Thank you very much.

    I've got more to go - that was just part of my macro. I am working through
    it a piece at a time.

    I may be back. . .

    "Jim Thomlinson" wrote:

    > Give this a try...
    >
    > ActiveSheet.Unprotect
    > Range("A24").Copy Range("A25")
    > Range("C24:G24").Copy Range("C25")
    > Range("H25").Value = 0
    > Range("I25").Value = 0
    > Range("J24").Copy
    > Range("M22").PasteSpecial Paste:=xlPasteValues
    > Range("N22").Formula = "=M22*0.2"
    > Range("N22").Copy
    > Range("J25").PasteSpecial Paste:=xlPasteValues
    > ActiveSheet.Protect
    >
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "Janet H" wrote:
    >
    > > Here is my code - I'm getting an error at the **. I'm trying to paste the
    > > result of my formula as a value.
    > >
    > > Also, I don't like the RC cell references. I tried to change them manually
    > > but then the macro doesn't run.
    > >
    > > I don't do much visual basic. I record a macro and then TRY to edit it.
    > >
    > > Thanks for any help.
    > >
    > > ActiveSheet.Unprotect
    > > Range("A24").Select
    > > Selection.Copy
    > > Range("A25").Select
    > > ActiveSheet.Paste
    > > Range("C24:G24").Select
    > > Application.CutCopyMode = False
    > > Selection.Copy
    > > Range("C25").Select
    > > ActiveSheet.Paste
    > > Range("h25").Select
    > > ActiveCell = "0"
    > > Range("i25").Select
    > > ActiveCell = "0"
    > > Range("J24").Select
    > > Application.CutCopyMode = False
    > > Selection.Copy
    > > Range("M22").Select
    > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > SkipBlanks _
    > > :=False, Transpose:=False
    > > Range("N22").Select
    > > Application.CutCopyMode = False
    > > ActiveCell.FormulaR1C1 = "=rc[-1]*0.2"
    > > Range("N22").Select
    > > Application.CutCopyMode = False
    > > Selection.Copy
    > > Range("J25").Select
    > > **Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > SkipBlanks _
    > > :=False, Transpose:=False
    > > ActiveSheet.Protect
    > > End Sub


  4. #4
    Jim Thomlinson
    Guest

    RE: Error in Code - Pasting Values

    Recording macros is a good start but a whole lot of stuff gets added that is
    not really necessary. A hint is where you see a select followed by a
    selection, you can pretty much get rid of it... if you know how it works...
    If you need more help just ask.
    --
    HTH...

    Jim Thomlinson


    "Janet H" wrote:

    > Wow. That's like speaking English. Thank you very much.
    >
    > I've got more to go - that was just part of my macro. I am working through
    > it a piece at a time.
    >
    > I may be back. . .
    >
    > "Jim Thomlinson" wrote:
    >
    > > Give this a try...
    > >
    > > ActiveSheet.Unprotect
    > > Range("A24").Copy Range("A25")
    > > Range("C24:G24").Copy Range("C25")
    > > Range("H25").Value = 0
    > > Range("I25").Value = 0
    > > Range("J24").Copy
    > > Range("M22").PasteSpecial Paste:=xlPasteValues
    > > Range("N22").Formula = "=M22*0.2"
    > > Range("N22").Copy
    > > Range("J25").PasteSpecial Paste:=xlPasteValues
    > > ActiveSheet.Protect
    > >
    > > --
    > > HTH...
    > >
    > > Jim Thomlinson
    > >
    > >
    > > "Janet H" wrote:
    > >
    > > > Here is my code - I'm getting an error at the **. I'm trying to paste the
    > > > result of my formula as a value.
    > > >
    > > > Also, I don't like the RC cell references. I tried to change them manually
    > > > but then the macro doesn't run.
    > > >
    > > > I don't do much visual basic. I record a macro and then TRY to edit it.
    > > >
    > > > Thanks for any help.
    > > >
    > > > ActiveSheet.Unprotect
    > > > Range("A24").Select
    > > > Selection.Copy
    > > > Range("A25").Select
    > > > ActiveSheet.Paste
    > > > Range("C24:G24").Select
    > > > Application.CutCopyMode = False
    > > > Selection.Copy
    > > > Range("C25").Select
    > > > ActiveSheet.Paste
    > > > Range("h25").Select
    > > > ActiveCell = "0"
    > > > Range("i25").Select
    > > > ActiveCell = "0"
    > > > Range("J24").Select
    > > > Application.CutCopyMode = False
    > > > Selection.Copy
    > > > Range("M22").Select
    > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > SkipBlanks _
    > > > :=False, Transpose:=False
    > > > Range("N22").Select
    > > > Application.CutCopyMode = False
    > > > ActiveCell.FormulaR1C1 = "=rc[-1]*0.2"
    > > > Range("N22").Select
    > > > Application.CutCopyMode = False
    > > > Selection.Copy
    > > > Range("J25").Select
    > > > **Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > SkipBlanks _
    > > > :=False, Transpose:=False
    > > > ActiveSheet.Protect
    > > > End Sub


  5. #5
    Janet H
    Guest

    RE: Error in Code - Pasting Values

    Jim, now that I've completed my macro, I need it to run on any line. I know
    that is something like Range("a" & "activecell.row") but I can't get that to
    work. (Values in M,N,O don't change)

    I've ** the values that can vary. The column will always be the same but the
    row will change. I always want to start on the last row that has a value in
    "a"

    See macro below

    Thanks again. I'm learning.

    ActiveSheet.Unprotect
    ** Range("A24").Copy Range("A25")
    **Range("C24:G24").Copy Range("C25")
    **Range("H25").Value = 0
    **Range("I25").Value = 0
    **Range("J24").Copy
    Range("M22").PasteSpecial Paste:=xlPasteValues
    Range("N22").Formula = "=M22*0.2"
    Range("N22").Copy
    **Range("J25").PasteSpecial Paste:=xlPasteValues
    Range("o22").Formula = "=M22*0.8"
    Range("o22").Copy
    **Range("j24").PasteSpecial Paste:=xlPasteValues
    **Range("k24").Value = "Reduced" & Chr(10) & "for Atty"
    **Range("k25").Value = "Atty Fees"
    ** Range("a26").Select (This is just to return them to a logical place on
    the form)
    ActiveSheet.Protect
    End Sub

    "Jim Thomlinson" wrote:

    > Recording macros is a good start but a whole lot of stuff gets added that is
    > not really necessary. A hint is where you see a select followed by a
    > selection, you can pretty much get rid of it... if you know how it works...
    > If you need more help just ask.
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "Janet H" wrote:
    >
    > > Wow. That's like speaking English. Thank you very much.
    > >
    > > I've got more to go - that was just part of my macro. I am working through
    > > it a piece at a time.
    > >
    > > I may be back. . .
    > >
    > > "Jim Thomlinson" wrote:
    > >
    > > > Give this a try...
    > > >
    > > > ActiveSheet.Unprotect
    > > > Range("A24").Copy Range("A25")
    > > > Range("C24:G24").Copy Range("C25")
    > > > Range("H25").Value = 0
    > > > Range("I25").Value = 0
    > > > Range("J24").Copy
    > > > Range("M22").PasteSpecial Paste:=xlPasteValues
    > > > Range("N22").Formula = "=M22*0.2"
    > > > Range("N22").Copy
    > > > Range("J25").PasteSpecial Paste:=xlPasteValues
    > > > ActiveSheet.Protect
    > > >
    > > > --
    > > > HTH...
    > > >
    > > > Jim Thomlinson
    > > >
    > > >
    > > > "Janet H" wrote:
    > > >
    > > > > Here is my code - I'm getting an error at the **. I'm trying to paste the
    > > > > result of my formula as a value.
    > > > >
    > > > > Also, I don't like the RC cell references. I tried to change them manually
    > > > > but then the macro doesn't run.
    > > > >
    > > > > I don't do much visual basic. I record a macro and then TRY to edit it.
    > > > >
    > > > > Thanks for any help.
    > > > >
    > > > > ActiveSheet.Unprotect
    > > > > Range("A24").Select
    > > > > Selection.Copy
    > > > > Range("A25").Select
    > > > > ActiveSheet.Paste
    > > > > Range("C24:G24").Select
    > > > > Application.CutCopyMode = False
    > > > > Selection.Copy
    > > > > Range("C25").Select
    > > > > ActiveSheet.Paste
    > > > > Range("h25").Select
    > > > > ActiveCell = "0"
    > > > > Range("i25").Select
    > > > > ActiveCell = "0"
    > > > > Range("J24").Select
    > > > > Application.CutCopyMode = False
    > > > > Selection.Copy
    > > > > Range("M22").Select
    > > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > SkipBlanks _
    > > > > :=False, Transpose:=False
    > > > > Range("N22").Select
    > > > > Application.CutCopyMode = False
    > > > > ActiveCell.FormulaR1C1 = "=rc[-1]*0.2"
    > > > > Range("N22").Select
    > > > > Application.CutCopyMode = False
    > > > > Selection.Copy
    > > > > Range("J25").Select
    > > > > **Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > SkipBlanks _
    > > > > :=False, Transpose:=False
    > > > > ActiveSheet.Protect
    > > > > End Sub


  6. #6
    Jim Thomlinson
    Guest

    RE: Error in Code - Pasting Values

    I am a little lost as to what exactly you are trying to accomplish so I will
    give you some general pointers that will hopefull help you out...

    To get the last populated Cell in Column a you want to use code similar to
    this

    dim lngLastRow as Long
    'Variable to store the row number of the last cell

    lngLastRow = cells(rows.count, "A").End(xlUp).row
    'Store the row number of the last cell in A

    range("A" & lngLastrow).copy range("B" & lngLastRow + 1)
    'Copy A??? to B??? one row down

    --
    HTH...

    Jim Thomlinson


    "Janet H" wrote:

    > Jim, now that I've completed my macro, I need it to run on any line. I know
    > that is something like Range("a" & "activecell.row") but I can't get that to
    > work. (Values in M,N,O don't change)
    >
    > I've ** the values that can vary. The column will always be the same but the
    > row will change. I always want to start on the last row that has a value in
    > "a"
    >
    > See macro below
    >
    > Thanks again. I'm learning.
    >
    > ActiveSheet.Unprotect
    > ** Range("A24").Copy Range("A25")
    > **Range("C24:G24").Copy Range("C25")
    > **Range("H25").Value = 0
    > **Range("I25").Value = 0
    > **Range("J24").Copy
    > Range("M22").PasteSpecial Paste:=xlPasteValues
    > Range("N22").Formula = "=M22*0.2"
    > Range("N22").Copy
    > **Range("J25").PasteSpecial Paste:=xlPasteValues
    > Range("o22").Formula = "=M22*0.8"
    > Range("o22").Copy
    > **Range("j24").PasteSpecial Paste:=xlPasteValues
    > **Range("k24").Value = "Reduced" & Chr(10) & "for Atty"
    > **Range("k25").Value = "Atty Fees"
    > ** Range("a26").Select (This is just to return them to a logical place on
    > the form)
    > ActiveSheet.Protect
    > End Sub
    >
    > "Jim Thomlinson" wrote:
    >
    > > Recording macros is a good start but a whole lot of stuff gets added that is
    > > not really necessary. A hint is where you see a select followed by a
    > > selection, you can pretty much get rid of it... if you know how it works...
    > > If you need more help just ask.
    > > --
    > > HTH...
    > >
    > > Jim Thomlinson
    > >
    > >
    > > "Janet H" wrote:
    > >
    > > > Wow. That's like speaking English. Thank you very much.
    > > >
    > > > I've got more to go - that was just part of my macro. I am working through
    > > > it a piece at a time.
    > > >
    > > > I may be back. . .
    > > >
    > > > "Jim Thomlinson" wrote:
    > > >
    > > > > Give this a try...
    > > > >
    > > > > ActiveSheet.Unprotect
    > > > > Range("A24").Copy Range("A25")
    > > > > Range("C24:G24").Copy Range("C25")
    > > > > Range("H25").Value = 0
    > > > > Range("I25").Value = 0
    > > > > Range("J24").Copy
    > > > > Range("M22").PasteSpecial Paste:=xlPasteValues
    > > > > Range("N22").Formula = "=M22*0.2"
    > > > > Range("N22").Copy
    > > > > Range("J25").PasteSpecial Paste:=xlPasteValues
    > > > > ActiveSheet.Protect
    > > > >
    > > > > --
    > > > > HTH...
    > > > >
    > > > > Jim Thomlinson
    > > > >
    > > > >
    > > > > "Janet H" wrote:
    > > > >
    > > > > > Here is my code - I'm getting an error at the **. I'm trying to paste the
    > > > > > result of my formula as a value.
    > > > > >
    > > > > > Also, I don't like the RC cell references. I tried to change them manually
    > > > > > but then the macro doesn't run.
    > > > > >
    > > > > > I don't do much visual basic. I record a macro and then TRY to edit it.
    > > > > >
    > > > > > Thanks for any help.
    > > > > >
    > > > > > ActiveSheet.Unprotect
    > > > > > Range("A24").Select
    > > > > > Selection.Copy
    > > > > > Range("A25").Select
    > > > > > ActiveSheet.Paste
    > > > > > Range("C24:G24").Select
    > > > > > Application.CutCopyMode = False
    > > > > > Selection.Copy
    > > > > > Range("C25").Select
    > > > > > ActiveSheet.Paste
    > > > > > Range("h25").Select
    > > > > > ActiveCell = "0"
    > > > > > Range("i25").Select
    > > > > > ActiveCell = "0"
    > > > > > Range("J24").Select
    > > > > > Application.CutCopyMode = False
    > > > > > Selection.Copy
    > > > > > Range("M22").Select
    > > > > > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > > SkipBlanks _
    > > > > > :=False, Transpose:=False
    > > > > > Range("N22").Select
    > > > > > Application.CutCopyMode = False
    > > > > > ActiveCell.FormulaR1C1 = "=rc[-1]*0.2"
    > > > > > Range("N22").Select
    > > > > > Application.CutCopyMode = False
    > > > > > Selection.Copy
    > > > > > Range("J25").Select
    > > > > > **Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > > > > > SkipBlanks _
    > > > > > :=False, Transpose:=False
    > > > > > ActiveSheet.Protect
    > > > > > End Sub


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1