Copy Data after last row containing data in Col G

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have the following code to copy data into Col G

When the data is extracted, I want the code to be amended, so it extracts it after the last row containing data in Col G

Your assistance is most appreciated



Code:
 Sub Variance_Extraction()

Dim ws As Worksheet, r As Range, msg As String, ff As String, Sp As Variant
For Each ws In Sheets
Set r = ws.Columns("a").Find("Variance")

If Not r Is Nothing Then
ff = r.Address
Do
         If 0.001 < Abs(Val(CStr(r.Offset(0, 4).Value))) Then

             msg = msg & ws.Name & " " & r.Address(0, 0) & ","
End If
Set r = ws.Columns("a").FindNext(r)
Loop Until ff = r.Address
End If

Next
If Len(msg) = 0 Then
MsgBox "No Variances Found"
Exit Sub
Else
'MsgBox msg
Sp = Split(msg, ",")
Worksheets("Macro").Range("G2").Resize(UBound(Sp) + 1).Value = Application.Transpose(Sp)
End If
Sheets("macro").Select
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
How about
VBA Code:
Worksheets("Macro").Range("G"&Rows.count).end(xlUp).Offset(1).Resize(UBound(Sp) + 1).Value
 
Upvote 0
Hi Fluff

Thanks for the help

Code should be-left out code in bold


Code:
 Worksheets("Macro").Range("G"&Rows.count).end(xlUp).Offset(1).Resize(UBound(Sp) + 1).Value  = Application.Transpose(Sp)
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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