I am a total n00b when it comes to excel and vba. Any help would be much appreciated.
There is data from a to k in excel. I am trying to: Check whether E>2, to export G(x), E(x), and J(x) for all lines (columns) where this is the case.
I can't manage to select properly, and joins this with conditional successfully. In addition, my pasting is super random. I am trying to export it to a given filename @ place, but haven't really gotten that far because cannot event export properly to different sheet in same workbook.
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim Value As Range
Dim Copyarea1 As Range
Dim Copyarea2 As Range
Dim Copyarea3 As Range
Dim Copymaster As Range
Dim Pastesheet As Range
Sheet4.Activate
sheet1.Activate
Set Copyarea1 = sheet1.Range("F2")
Set Copyarea2 = sheet1.Range("H2")
Set Copyarea3 = sheet1.Range("I2")
Set Copymaster = Union(Copyarea1, Copyarea2, Copyarea3)
sheet1.Select
For Each Value In Range(["H2:H2539"])
If Value > 2 Then
Value.Select
Selection.Copy
Else: ActiveCell.Offset(1, 0).Activate
End If
If Value = "" Then Exit Sub
Sheet4.Select
Selection.PasteSpecial paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, 0).Activate
sheet1.Activate
Next
Application.ScreenUpdating = True
End Sub
When I replace Value with copy master I get correct initial selection but fail at offsetting. and the export part is no good. Only values to be copied, cells have formulas.