Copy and Paste Cell Value Only - Not Formula

aavvijit

Board Regular
Joined
Mar 23, 2009
Messages
75
Hi
  1. I have data from A7 to Y22 (this range is variable) in sheet 1 of file 1……​
  2. In above range some of the column has hardcoded value data and some of the column has formula.​
  3. Now I want to copy the above range of data (range may be variable range) and paste it to another file​
  4. But while copying, it should copy the cell having only hardcoded value and formula cell should be skipped.​
  5. At present I am using he following VBA, but same is working only if I execute the same in same workbook but it is not working in another workbook.​
  6. At present I am moving between two workbooks with CTRL+F6 command.​

Please help in correcting the VBA
VBA Code:
Sub Abb1()
Dim rngDestination As Range
Dim colNum As Long, i As Long

colNum = Selection.Columns.Count

Set rngDestination = Application.InputBox(Prompt:="Enter destination cell", Type:=8)

For i = 1 To colNum
If Selection.Columns(i).Range("A1").HasFormula = False Then
Selection.Columns(i).Copy Destination:=rngDestination.Offset(0, i - 1)
End If
Next i

End Sub

Thanks,
AB
 
Last edited by a moderator:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi
Any help will be appreciated .......... pls. help in finding the solution in above matter.

Regards
Abhijit
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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