• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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