Copy and Paste or Equal Value

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi can anyone help?

I am copying data from "AJ2:AS & lRowAJ" to "N2:W & lRowAJ" and "X2:AG & lRowAJ"

If I use the following line it copies fine

[CODE
.Range("AJ2:AS" & lRowAJ).Copy
.Range("N2:W" & lRowAJ, "X2:AG" & lRowAJ).PasteSpecial Paste:=xlPasteValues][/CODE]

I would prefer to use the following line but I get errors in "X2:AG" is there something I can add to this line to have it equal the values in "AJ:AS"

[CODE
.Range("N2:W" & lRowAJ, "X2:AG" & lRowAJ) = .Range("AJ2:AS" & lRowAJ).Value][/CODE]

ie

NOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
1NxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxtNxt
21012345671
#N/A######################N/A#N/A1012345671
3
4
5
6
7
8
9
10

<tbody>
</tbody>


Regards

pwill
 
Last edited:

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
685
dont know about the 1 liner but this is still better than copy/paste

Code:
.Range("N2:W" & lRowAJ).Value2 = .Range("AJ2:AS" & lRowAJ).Value2
.Range("X2:AG" & lRowAJ).Value2 = .Range("AJ2:AS" & lRowAJ).Value2
 

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Thanks JumboCactuar,

I just had the same idea myself lol works just the same, maybe someone else will come up with a one linner out of interest?

Thanks away much appreciated

pwill
 

Watch MrExcel Video

Forum statistics

Threads
1,102,784
Messages
5,488,858
Members
407,658
Latest member
Arias610

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top