I'm making calculation form where you can enter element quantity and select materials from drop down list on sheet1 (all info will go to the sheet2) and in sheet2 you can change same materials that were set in sheet1 to other from drop down list and it automatically update info in sheet1. I have the code that works perfectly(see code below) and it works both ways. Question is that the code for checking and changing the values is ok with me but it has to to be repeated for about 10 different positions(ranges) that are defined next to 51 different element calculations and it need to be entered 1000+ times. If there is possibility to somehow group that 10 position with one code similar to "loop" then it would be repeated just for 100+ times :)
the idea is to be able to adjust "materials"in both sheets see picture enter image description here
Main code is in sheet and yes it is _change
calculation sheet (sheet1)
Private Sub Worksheet_Change(ByVal Target As Range)
Call FloorElementExchange1
End Sub
main sheet(sheet2)
Private Sub Worksheet_Change(ByVal Target As Range)
Call FloorElementExchange2
End Sub
and all another code that actually do the check and replacement of value is in module (sub FloorElementExchange1()) that goes like this:
sub FloorElementExchange1()
If Worksheets("CALCULATION").Range("N67") <> Worksheets("main sheet").Range("F44") Then
Worksheets("main sheet").Range("F44").Value = Worksheets("CALCULATION").Range("N67").Value
End If
sub FloorElementExchange2()
If Worksheets("main sheet").Range("F44") <> Worksheets("CALCULATION").Range("N67") Then
Worksheets("CALCULATION").Range("N67").Value = Worksheets("main sheet").Range("F44").Value
End If
If A <> B Then A = B
: Easier to just goA=B
and forget the check, because that is what you end up with anyway. – AJD