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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,822
Members
452,946
Latest member
JoseDavid

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