Create a code vba to collect the value of a specific cell from two different columns and put the result in another column

Dayski147

Banned user
Joined
Apr 12, 2022
Messages
89
Office Version
  1. 2016
Platform
  1. Windows
I want to calculate the sum of each cell from the first column with the corresponding cell in the second column and put the result in the third column....and so only the end of the column

Example:
code vba:
Range ("J11")=SIERREUR(SOMME(H11:I11)/2;"")
Range ("J12")=SIERREUR(SOMME(H12:I12)/2;"")
Range ("J13")=SIERREUR(SOMME(H13:I13)/2;"")

And in the case that the column cells are empty, it does not put the formula
to the end of the column

Please perform the same task on all colored columns



 
VBA Code:
Sub delete()
For i = 8 To 49 Step 3
    Range(Cells(11, i + 2), Cells(55, i + 2)).ClearContents
Next
End Sub
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Thank you all how can I make it to the last cell written in column b
 
Upvote 0
code for generate value:
VBA Code:
Sub test()
lr = Cells(Rows.Count, "J").End(xlUp).Row
For i = 8 To 49 Step 3
    Set u = Range(Cells(11, i + 2), Cells(lr, i + 2))
    u.Value = Evaluate("=(" & Range(Cells(11, i), Cells(lr, i)).Address & "+ " & Range(Cells(11, i + 1), Cells(lr, i + 1)).Address & ")/2")
Next
End Sub

for delete
VBA Code:
Sub test()
lr = Cells(Rows.Count, "J").End(xlUp).Row
For i = 8 To 49 Step 3
      Range(Cells(11, i + 2), Cells(lr, i + 2)).ClearContents
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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