Lock Cell with IF function

MariPip

New Member
Joined
Jul 16, 2014
Messages
29
Hello
I am in desperate need for help with this, so any answer would be really useful!
I have two worksheets, lets call them Worksheet1 and Worksheet2.
Worksheet 1 is a sample formulary with a reset button, so that everytime you fill it and then press the button, a pdf of it is created and the cell on to which we insert the details of each sample are deleted.
Worksheet 2 is a Summary formulary, which collects information from each sample (sample number and some results), which it gets from Worksheet 1 using a simple =IF(...) function.
My problem is that when I reset Workhseet 1 I lose the data that had gone onto Worksheet 2.
So I wish to find a way to lock the cells in Worksheet 1 after they have collected the information from Worksheet 1, or something of that sort.
THANK YOU!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hello,

how are you resetting Worksheet 1, with VBA code? If so, copying the data in Worksheet 2 as values only can be incorporated into the code, onto another sheet. What do you want to happen with this data after resetting?
 
Upvote 0
Hi, first of all thank you for the answer
well, I've been thinking and an easier way would be to come up with a MACRO (which will be asigned to a button) that copies the value in cell ("B4") (Worksheet1) to the next available cell in C column Worksheet2 (Starting from row 27) and the value in cell ("H20") in Worksheet 1 to the cell from the same row as the other one but in column L.
I hope you got my explanation right :)
 
Upvote 0
Hello,

does this code work as expected?

Code:
Sub copy_sht_1_to_2()
    With Sheets("Sheet1")
        .Range("b4").Copy
        Sheets("Sheet2").Range("C26").End(xlDown).Offset(1, 0).PasteSpecial (xlValues)
        .Range("H20").Copy
        Sheets("Sheet2").Range("L" & Sheets("Sheet2").Range("C27").End(xlDown).Row).PasteSpecial (xlValues)
    End With
End Sub
 
Upvote 0
No, it sends an error message for "Application defined or object defined error" and highlights " Sheets("RESUMO").Range("C27").End(xlDown).Offset(1, 0).PasteSpecial (xlValues)"
Do you know what could be going on??
Thank you for the reply :)
 
Upvote 0
Hello,

might be that it is going to the last row on the entire spreadsheet, try

Code:
Sheets("Sheet2").Range("C65536").End(xlup).Offset(1, 0).PasteSpecial (xlValues)

instead, and

Code:
Sheets("Sheet2").Range("L" & Sheets("Sheet2").Range("C65536").End(xlup).Row).PasteSpecial (xlValues)
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,109
Members
452,302
Latest member
TaMere

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