[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

how do i write in Macro/VBA that column H = Column G-F for the current region?

i wrote a script in macro which entering values to columns G and F and now how do i write macro that column H will be the subscration of column F minus G?

Thanks
0
gvilbis
Asked:
gvilbis
2 Solutions
 
Michael FowlerSolutions ConsultantCommented:
Sorry not sure exactly what you are after. Could you supply an example file to give us a better idea of what you need

Michael
0
 
jason987Commented:
The below code uses the last row of g and fills colum H with the formula:

Sub test()


Dim wks As Worksheet
Dim LastRow As Integer

Set wks = ActiveWorkbook.Sheets("Sheet1")


With wks
    LastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
    .Range("H1:H" & LastRow).Formula = "=RC[-2]-RC[-1]"
End With

End Sub

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now