Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-05-2018, 03:12 PM
rsrasc rsrasc is offline Need Help With a Macro Windows 10 Need Help With a Macro Office 2013
Competent Performer
Need Help With a Macro
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default Need Help With a Macro

Hi all,



I have a payroll file with an average of 45 tabs. The tabs are named as followed:

Page 1
....
Page 50

In any given tab, there may be under Column Y, the letter G and the associated dollar value in column Z.

I would like with a macro, be able to move (maybe cut and Paste) the information one row up (same position-Column Y and Column Z) and then be able to delete the entire row where the letter G and their corresponding value was before.

For example, in Page 20 in this file, in cell Y20, there is a letter G, and in cell Z20, there is a dollar value in the amount of $225.00. With a macro, I would like move the information one row up (to row 19), and after this I would like the macro to delete the entire row 20.

For example, in Page 30 in this file, in cell Y24, there is a letter G, and in cell Z24, there is a dollar value in the amount of $324.00. With a macro, I would like move the information one row up (to row 23), and after this I would like the macro to delete the entire row 24.

Hope this is not confusing.

Well, thank you in advance for your assistant and cooperation.

Regards,
rsrac
Reply With Quote
  #2  
Old 05-05-2018, 06:26 PM
Logit Logit is offline Need Help With a Macro Windows 10 Need Help With a Macro Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Code:
Option Explicit

Sub Button1_Click()
    Dim x As Long
    Sheet1.Select

    Application.ScreenUpdating = False
    For x = 2 To ThisWorkbook.Sheets.Count
        If Sheets(x).Name <> "Sheet1" Then
            Sheets(x).Select
            If Range("Y20").Value = "G" Then  'searches for term G
                Range("Y19:Z19").Value = Range("Y20:Z20").Value
                Range("Y20").EntireRow.Delete
            End If
        End If
    Next x
    Application.ScreenUpdating = True
End Sub
Attached Files
File Type: xlsm Search Term All Sheets Copy Paste Other Row.xlsm (23.8 KB, 11 views)
Reply With Quote
  #3  
Old 05-05-2018, 09:31 PM
NoSparks NoSparks is offline Need Help With a Macro Windows 7 64bit Need Help With a Macro Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

My offering...
Code:
Sub testing()
Dim ws As Worksheet, fndRng As Range
For Each ws In ThisWorkbook.Sheets
    With ws.Range("Y:Y")
        Set fndRng = .Find(What:="G", LookIn:=xlValues, LookAt:=xlWhole, _
            SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True)
        If Not fndRng Is Nothing Then
            fndRng.Offset(-1).Resize(, 2).Value = fndRng.Resize(, 2).Value
            fndRng.EntireRow.Delete
        End If
    End With
Next ws
End Sub
Reply With Quote
  #4  
Old 05-06-2018, 03:15 AM
rsrasc rsrasc is offline Need Help With a Macro Windows 10 Need Help With a Macro Office 2013
Competent Performer
Need Help With a Macro
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Thank you both for your postings. Working great! Much appreciated.
Reply With Quote
  #5  
Old 05-06-2018, 08:18 AM
Logit Logit is offline Need Help With a Macro Windows 10 Need Help With a Macro Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

You are welcome.

Hello NoSparks ! How have you been ?
Reply With Quote
  #6  
Old 05-10-2018, 05:01 AM
Shashi Kant Shashi Kant is offline Need Help With a Macro Windows 7 32bit Need Help With a Macro Office 2016
Novice
 
Join Date: May 2018
Posts: 16
Shashi Kant is on a distinguished road
Default Query Ansered

Code:
Private Sub CommandButton1_Click()
    Dim ws As Worksheet
    Dim i As Integer
    For Each ws In Worksheets
        ws.Select
        For i = 1 To ws.Cells(Rows.Count, "Y").End(xlUp).Row
            If ws.Cells(i, "Y").Value = "G" And ws.Cells(i, "Z") > 1 Then
                ws.Range(ws.Cells(i - 1, "Y"), ws.Cells(i - 1, "Z")).Value = _
                ws.Range(ws.Cells(i, "Y"), ws.Cells(i, "Z")).Value
                ws.Cells(i, "Y").Select
                Selection.EntireRow.Delete Shift:=xlUp
            End If
        Next i
    Next ws
End Sub
Attached Files
File Type: xlsm Query.xlsm (28.0 KB, 9 views)

Last edited by Pecoflyer; 05-12-2018 at 12:15 AM. Reason: Added code tags
Reply With Quote
  #7  
Old 05-12-2018, 12:15 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Need Help With a Macro Windows 7 64bit Need Help With a Macro Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

@Shasi
Hi and welcome
please always wrap code with code tags ( click Go advanced - select code - click #)
I did it for you on this thread. Please do the same in your other posts
Thx
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With a Macro Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?] Le_Blanc Word VBA 10 03-22-2021 11:38 AM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
Need Help With a Macro Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM
custom icon, undo/redo for macro, permanent macro Rapier Excel 0 08-05-2013 06:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft