Good afternoon community,
I am trying to work with VBA in Excel to try to apply this knowledge in my master's thesis, but I have some questions.
I'm trying to create a function in VBA that populates cells by a given value. In the next image I have two frames, one with values in the vertices and another one filled with value 1. The left frame represents a surveillance camera, which is in cell B1. In the right frame is supposed to appear the coverage area of that same camera. The chamber area occupies 10 cells.
The code I have is the following:
Sub Limpar()
Range("G5:J8") = ""
End Sub
Sub Executar()
If Cells(5, "B").Value = 1 Then Preencher
End Sub
Sub Preencher()
Dim contador As Integer
contador = 10
Do While contador > 0
Range("G5:J8") = 1
contador = contador - 1
Loop
End Sub
And your result is this:
Asyoucanseemyfunctionfillseverything,andthegoalwastofillonly10cells.WhatIwantedwassomethingliketheoneinthenextimage:
Does anyone know how to do in VBA for the right frame to display only the number of cells filled by the camera area? That in this case 10 filled cells should appear. I know that my code fills the whole frame, but that's not what I was trying to do, I wanted to fill the grid with the grid until it matches the 10 squares corresponding to the chamber area of cell B5.
If I can get to one camera, I'll probably get to other cameras in different areas and put them at different vertices.
Thank you for helping me.