Transfer Data, Clear only values not formula - VBA

srikanth58

Board Regular
Joined
Jun 8, 2006
Messages
58
Hi,
I have two worksheets, DataEntry and DataSheet

'DataEntry' has two named ranges
A1:A10 ---- 'xxx' and A15:A25 ---- 'yyy'
The ranges have formula e along with user input figures.

Can you please help me with VBA,
With a command button I want to transfer range ('xxx' and 'yyy') VALUES to next available row starting from A1:A20 in 'DataSheet'.
Once data is transferred clear ONLY VALUES (not formula e) from named ranges in DataEntry sheet, ready for next data entry.

Now clear or delete is removing formula e too, and inconsistent data is entered in DataSheet.

Thanks in advance
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

stefankemp

Board Regular
Joined
Mar 11, 2010
Messages
136
Code:
sub cmdButton_Click()

nextrow = sheets("Datasheet").cells(sheets("Datasheet").rows.count,1).end(xlup).row+1

sheets("Dataentry").[xxx].copy
sheets("Datasheet").cells(nextrow,1).pastespecial paste:=xlpastevalues

sheets("Dataentry").[yyy].copy
sheets("Datasheet").cells(nextrow+11,1).pastespecial paste:=xlpastevalues

sheets("Dataentry").[xxx].specialcells(xlCellTypeConstants).clearcontents
sheets("Dataentry").[yyy].specialcells(xlCellTypeConstants).clearcontents

end sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,629
Messages
5,838,454
Members
430,549
Latest member
jayjay2022

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
Top