copy paste question

nburaq

Board Regular
Joined
Apr 2, 2021
Messages
220
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi Gents,
I searched all over the internet but is there any way to paste data shown as below
paste.png

so basically I would like to paste the values in column F exactly the same range in column B. However, when I copy this values in column B it overwrites the values! and all ages disappear. I tried skip blanks option in my scenario but no luck! (to be honest for small amount of data it works ) Any suggestion? Thanks for your help!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
you wouldnt paste, youd scan thru the list writing the values.

Code:
Public Sub SetNA()
Dim rng As Range
Dim r As Long

Range("A2").Select
Set rng = ActiveSheet.UsedRange
r = 2

While r <= rng.Rows.Count
     If ActiveCell.Offset(0, 1).Value <> "" Then ActiveCell.Offset(0, 5).Value = "NA"
     
     ActiveCell.Offset(1, 0).Select  'next row
     r = ActiveCell.Row
Wend
End Sub
 
Upvote 0
you wouldnt paste, youd scan thru the list writing the values.

Code:
Public Sub SetNA()
Dim rng As Range
Dim r As Long

Range("A2").Select
Set rng = ActiveSheet.UsedRange
r = 2

While r <= rng.Rows.Count
     If ActiveCell.Offset(0, 1).Value <> "" Then ActiveCell.Offset(0, 5).Value = "NA"
    
     ActiveCell.Offset(1, 0).Select  'next row
     r = ActiveCell.Row
Wend
End Sub
Thanks for the help, so if NA value is in column G instead F then should offset value be (0,6) ?
or the past value is not in column B but C then which values in formula should be changed?
 
Upvote 0
How about
VBA Code:
Sub nburaq()
   Dim Rng As Range
   
   With Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
      .Value = Evaluate(Replace(Replace("if(@<>"""",@,if(#="""","""",#))", "@", .Address), "#", .Offset(, 4).Address))
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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