Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all 49833 articles
Browse latest View live

Macro to hide last column in a pivot table

$
0
0
I have a report that has percentage of row totals that just displays as 100% for the grand total column. I want to hide that percentage of row column does anyone have or know a macro that can do that? it will be a very big help. I've attached the excel file below to see the pivot tables.
Attached Files

ListBox Selections To Change ReportFilter on PivotTable and then Execute Macro

$
0
0
Hello,

I have created a ListBox1 that is populated by a PivotTables(1).PivotField(6) (which is a Report Filter called "Select Customer"). I could not figure out how to use PageField to select the Report Filter, so I did a work around.

Code:

Private Sub CommandButton2_Click()

Dim PF As PivotField
      Dim i As Integer
        Set PF = Sheets("L to L").PivotTables(1).PivotFields(6)
        With Sheets("Select Customers").ListBox1
        .Clear
            For i = 1 To PF.PivotItems.Count
            .AddItem PF.PivotItems(i)
            Next
        End With
End Sub

I am now attempting to change the Report Filter in the PivotTable to match the selection made in the ListBox1. I then want a macro to execute on that selection. I then want it to repeat the process for each selection made.


Code:

Sub CreateUsageReportsOnSelection()

'Turn ScreenUpdating OFF'
Application.ScreenUpdating = False

Dim UserSels() As Variant
Dim SelCnt As Long
Dim i As Long

SelCnt = 0
With Sheets("Select Customers").ListBox1
    For i = 0 To .ListCount - 1
        If .Selected(i) Then
            SelCnt = SelCnt + 1
            ReDim Preserve UserSels(1 To SelCnt)
            UserSels(SelCnt) = .List(i)
        End If
    Next i
End With
   
    If SelCnt > 0 Then
   
'Change the Customer Selection in the Report Filter on PivotTable'
Sheets("L to L").PivotTables(1).PivotFields(6).CurrentPage = .Selected

'Refresh WorkBook'
ActiveWorkbook.RefreshAll

'Selects Sheet with PivotTable'
Sheets("L to L").Select


'Creates a Usage Report and Formats for e-Mail THIS IS THE MACRO I WANT TO RUN AFTER THE SELECTION CHANGES THE PivotTable Filter to match the text of the selection!!!
'
  Cells.Select
    Selection.Copy
    Sheets.Add after:=Sheets(Sheets.Count)
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A1").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft
    Columns("A:A").EntireColumn.AutoFit
    Rows("2:2").Select
    Selection.Delete Shift:=xlUp
    Range("A3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Delete Shift:=xlToLeft
    Range("A3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Delete Shift:=xlToLeft
    Columns("A:A").EntireColumn.AutoFit
    Columns("B:B").EntireColumn.AutoFit
    Columns("C:C").EntireColumn.AutoFit
    Columns("D:D").EntireColumn.AutoFit
    Range("A1:D1").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge
    Selection.Style = "Note"
    Range("A3:D3").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Style = "60% - Accent1"
    Range("D4:D65536").Select
    Selection.Style = "Currency"
    Range("C4").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("B4").Select
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("A4").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("A:A,C:C,D:D").Select
    Range("D2").Activate
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
    End With
    Range("A:A,C:C,D:D").Select
    Range("D2").Activate
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
    End With
    Range("B4").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Columns("B:B").EntireColumn.AutoFit
   
'Creates Temproary Code to Name Sheet'
    Range("K1").Select
    ActiveCell.FormulaR1C1 = "=IF(R2C11=FALSE, (IF(LEN(R1C1)>30,LEFT(R1C1,30),R1C1)),R2C12)"
    Range("K2").Select
    ActiveCell.FormulaR1C1 = "=SheetExists((IF(LEN(R1C1)>30,LEFT(R1C1,30),R1C1)))"
    Range("L2").Select
    ActiveCell.FormulaR1C1 = "=IF(LEN(R1C1)>30,LEFT(R1C1,30),R1C1) & ""2"""
   
'Renames Sheet'
ActiveSheet.Name = [K1]

'Deletes Temporary Code Used to Format Sheet Name'
Range("K1").Select
Selection.Delete Shift:=xlToLeft
Range("K2").Select
Selection.Delete Shift:=xlToLeft
Range("L2").Select
Selection.Delete Shift:=xlToLeft

'Return to Sheet with the PivotTable'
Sheets("L to L").Select

 Else
        MsgBox "No Selections Made.", vbInformation
    End If

'Turn ScreenUpdating ON'
Application.ScreenUpdating = True

End Sub

There is probably a much easier way to do this? Can anyone help?

[SOLVED] If statement to end sub or continue

$
0
0
I'm battling with my first VAB IF statement. If the value of cell F14 is <> 0, then display a msg box and exit the macro. If no value in F14 then to continue to print

Code:

    If Range("f14").Value <> 0 Then
    MsgBox ("This Certificate of Practical Completion has already been run")
   
    End If
   
    Application.ScreenUpdating = False
    Range("F14").Select
    Selection.Copy
    Range("AB2").Select
    ActiveSheet.Paste
    Application.ScreenUpdating = True
    Application.Wait Time + TimeSerial(0, 0, 2)
    Application.ScreenUpdating = False
    Sheets("Print_CC1").Select
    Range("B2").Select
    Range("PrintCC1").Select
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.275590551181102)
        .RightMargin = Application.InchesToPoints(0.275590551181102)
        .TopMargin = Application.InchesToPoints(0.275590551181102)
        .BottomMargin = Application.InchesToPoints(0.15748031496063)
        .HeaderMargin = Application.InchesToPoints(0.236220472440945)
        .FooterMargin = Application.InchesToPoints(0.31496062992126)
        .CenterHorizontally = True
        .CenterVertically = True
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 2
    Application.ScreenUpdating = True
End Sub

[SOLVED] Check Sheet Existence Continues to Raise Error

$
0
0
Seemingly trivial task - I have looked here and elsewhere, and tried a multitude of functions and subs dedicated to testing for existence of a worksheet equal to a string name - all with no luck.

I'm attempting to loop a range (rDept) and, if a sheet already exists equal to the active cell (rCell) in the loop range, copy the row range to the next available row of the sheet; if not, create a new worksheet with the name equal to the active cell of the loop and repeat .value = .value.

I continue to get a subscript out of range error at line
Code:

Set wsTemp = wb.Sheets(sDept)
Many thanks.

Code:

Dim wb as Workbook
Set wb = ThisWorkbook

        With wsMaster
            Set rHeader = .Range("A1", .Range("A1").End(xlToRight))
            Set rDept = .Range("Q2", .Range("Q2").End(xlDown))
            For Each rCell In rDept
                sDept = CStr(rCell)
                Set rSource = rCell.Offset(, -16).Resize(1, 20)
                On Error Resume Next
                Set wsTemp = Nothing
                Set wsTemp = wb.Sheets(sDept)
                If Not wsTemp Is Nothing Then

                    With Sheets(sDept)
                        Set rDest = .Range("A1000").End(xlUp).Offset(1).Resize(1, 20)
                        rDest.Value = rSource.Value
                    End With
                Else
                    Set wsTemp = wb.Sheets.Add(, Sheets.Count)
                    With wsTemp
                        .Name = sDept
                        .Range("A1:T1").Value = rHeader.Value
                        Set rDest = .Range("A1000").End(xlUp).Offset(1).Resize(1, 20)
                        rDest.Value = rSource.Value
                    End With
                End If
            Next rCell
        End With

transfer information from one sheet to multiple sheets if yes entered

$
0
0
Master sheet with columns A-N. Would like to transfer information from columns A-G (from master sheet) if yes entered in columns H-N. Example if yes entered in column H, information from columns A-G transferred to Sheet H. Information from columns A-G could be transferred to multiple sheets if yes entered in any or multiple H-N columns.

Need help witl Hyperlink in Email body

$
0
0
Hello everyone,

I'm having an issue with the hyperlink I'm trying to make.

The hyperlink is contained in an email created by the macro. The hyper link needs to refer to a file name provided in cell E3.

I'm having two issues.

1. The hyperlink is not registering spaces and stops at the first space therefore the file path is not complete (it should be R:\DESIGN\DESIGN TEMPLATE\Special Purchase Request\ but actually it comes out as R:\DESIGN\DESIGN)

2. How do I refer to the cell to get the filename?

Code:

Sub Print_and_Email()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Office 2000-2013
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

        strbody = "Hi Rory,<br></br>" & _
              "<br>A new Special Purchase Request form has been saved in the folder.</br>" & _
              "<br></br><br></br>Please can you provide a quotation for the items listed." & _
              "<br></br><br></br><A HREF=file:\\R:\DESIGN\DESIGN TEMPLATE\Special Purchase Request\ & filename>Special Purchase Request link</A>" & _
              "<br></br><br></br>Thank you" & _
              "<br></br><br></br>" & Range("C2").Value


    On Error Resume Next
    With OutMail
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = "Special Purchase Request - " & Range("E2").Value
        .HTMLBody = strbody & "<br>" & .HTMLBody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Send  'or use .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
   
' SavePDF Macro
'Sheets("Request Form").Select
'ChDir "L:\"
'ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("Data!E1").Value _
', Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
':=False, OpenAfterPublish:=True
'Sheets("Data").Select

End Sub

Continue VBA code to next line

$
0
0
Hi guys

I'm trying to continue a long line of selected ranges to the next, but it keeps coming up red, This is how i've written part of it (example only)

Code:

Range("D9,D10,D11,D12,D15" _
E9,E10,E11,E12,E13,E14,E15").Select

I dont know what i'm missing, Reason I have to select each one individually rather than a range is because of this type of code below:

Code:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With

This one above was a recorded macro to put a border around all the cells in a selected range, but then went red on the last 2 selections (which are not on here) So only way for it to work for me is to select each individual cell, and then run the code above. I think the last 2 lines used to say "inside horizontal & inside vertical" which is where the code stopped on the debugging.

How can something that got recorded not run again??????????


Thanks
This is being run on the 2003 version.

Copy Protected workbook to a New Workbook


Move entire row to other sheet without inserting new rows

$
0
0
hi,

I have searched the below code in this forum. It work but not that perfect. After all rows with "y" on column "J" are moved, it keeps inserting new rows when user clicks on the button (by mistake). I tried to search on the remedy but failed. kindly help.



Code:

Sub MoveMatched_GL()
Dim lr As Long
Application.ScreenUpdating = False

    Sheets("GL ENTRIES").Unprotect "classA"
    Range("A3").EntireRow.Insert Shift:=xlDown
    lr = Sheets("GL ENTRIES").Cells(Rows.Count, "J").End(xlUp).Row
    If lr < 3 Then Exit Sub
    LR1 = Sheets("GL-Cleared").Cells(Rows.Count, "A").End(xlUp).Row + 1
        With Sheets("GL ENTRIES").Range("J3:J" & lr)
            .AutoFilter
            .AutoFilter Field:=1, Criteria1:="Y", _
            Operator:=xlOr, Criteria2:="y"
            Sheets("GL-Cleared").Unprotect "classA"
            .SpecialCells(xlCellTypeVisible).EntireRow.Copy Destination:=Sheets("GL-Cleared").Range("A" & LR1)
            .SpecialCells(xlCellTypeVisible).EntireRow.Delete
   
            Sheets("GL-Cleared").Select
            Cells.Select
            Selection.Locked = True
            Selection.FormulaHidden = False
            Sheets("GL-Cleared").Protect "classA"
   
            End With
            Sheets("GL ENTRIES").Select
            Range("A1:J1").Select
            Selection.Locked = True
            Selection.FormulaHidden = True
            Rows("2:2").AutoFilter
            ActiveSheet.Protect "classA", DrawingObjects:=False, Contents:=True, Scenarios:= _
            False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
            AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
            :=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
            AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
            AllowUsingPivotTables:=True
            Range("J3").Select
           
   

End Sub

[SOLVED] Trouble with sub that runs on pressing enter after modifying cell's content

$
0
0
I have the following sub which is designed to run another sub, "mySub", once I change the value of cell H10:

Code:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("$H$10")) Is Nothing Then
    mySub
    End If
End Sub

mySub basically goes to another workbook, modifies some values in it and comes back to the workbook where mySub resides. If I run mySub by itself, it runs fine, but if I attempt to activate it with the code above, it seems to run on a loop, going back and fourth between the two workbook endlessly. Any clues as to why? I used this code before and it worked well.

Thanks.

macro for select empty cells and coloring them

$
0
0
hi again atm im using this code
Code:

Private Function Provera() As Boolean
    Dim S1 As String, S2 As String
    Dim lRow As Long, i As Long
    Dim ws As Worksheet

    Set ws = ActiveWorkbook.Sheets("pppdp")

    With ws
        If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
            lRow = .Range("A:R").Find(What:="*", _
                          After:=.Range("A19"), _
                          Lookat:=xlPart, _
                          LookIn:=xlFormulas, _
                          SearchOrder:=xlByRows, _
                          SearchDirection:=xlPrevious, _
                          MatchCase:=False).Row
        Else
            lRow = 1
        End If

        Provera = Application.WorksheetFunction.CountA(.Range("A19:R" & lRow)) _
            = .Range("A19:R" & lRow).Cells.Count
    End With
    With Sheets("pppdp")
    ActiveSheet.Unprotect Password:="markop"
    .Range("A19:R" & .Range("A" & Rows.Count).End(xlUp).Row).Interior.ColorIndex = xlNone
    End With
End Function
Sub color()
ActiveSheet.Unprotect Password:="markop"
With Sheets("pppdp")
  .Range("A19:R" & .Range("A" & Rows.Count).End(xlUp).Row).Interior.ColorIndex = xlNone
  If Not Provera Then
    .Range("A19:R" & .Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeBlanks).Interior.ColorIndex = 3
  End If
End With
ActiveSheet.Protect Password:="markop"
End Sub

but i have few more cells to check and color them in red like one in code... the cells i need to check is c4:c8, i try to do something but i colored a1:r18 any one have suggestion?

Using a drop-list to categorize and insert cells

$
0
0
Please see the attached file as I feel it explains it the best.

Essentially, I am creating a template were users can categorize items they input with a drop-list.

STEP 1: User lists their items that need to be categorized in F4, F5, F6 ...and so on.

STEP2: The user then uses a drop list in H4 to "categorize" the item in F4. And the drop list in H5 to categorize the item in F5, etc.

STEP 3: Excel reads what the item in F4 has been categorized as in H4, and adds it under the appropriate cell in the template located in Column A.


EXAMPLE

STEP 1: The user adds "advertising", "bad debt" and "electric" to cells F4, F5 and F6, respectively.

STEP 2: The user clicks the drop-list in H4 and selects "Selling". This effectively tags "advertising" as type "Selling". He tags bad debt in F5 as selling in H5, and electric in F6 as Special 1 in H6.

STEP 3: Excel adds the data automatically so it looks like my attached example.


I also posted this question at OZGrid and VBAExpress, but have not gotten any replies.
Attached Files

Close Userform from within child Userform

$
0
0
Hello everyone. I faced with a problem I cannot solve

I have a userform called "NewEngineer". In this Userform I have a textBox, and when "AfterUpdate" is triggered, child userform is displayed. Here user can enter additional data. There is a cancel button on a child userform. The button contains the simple code

Code:

Private Sub CancelButton_Click()
    Unload Me
    Unload NewEngineer
End Sub

But when I press that button (to close both userforms) I got Error

Code:

-2147417848 (800101108) Automation Error The object invoked has disconnected from its clients
When I press debug button on error message, the following libe of code is higlighted

Code:

Sub Macro22(control As IRibbonControl)
    NewEngineer.Show <<<<
End Sub

Note that This code located in a module

please help me to unload both userforms from within child userform when cancel button (on child userform) is pressed.


Create Separate Workbook and Move any previous versions

$
0
0
Hi,

I haven't taken a whack at this yet, as I don't have a tremendous idea of how to get started; but ultimately the following is what I'm trying to do, just wondering about any thoughts on how to approach this.

1. WorkbookZZZ.xlsx contains sheetX, I want to search if there's a preexisting sub workbook WorkbookZZZ.Sheetx.xlsx

2. If pre-existing then move to a Drafts folder (if there's one, if not then create and move)

3. Once moved or if no preexisting; Create WorkbookZZZ.Sheetx.Date.xlsx from Sheetx

I am still learning all the wonders of VBA, and I'm sure this is simple for a lot of folks, I just don't want to go the route of many of my tasks so far which take have take a lot more time than they should have from not understanding some of the syntax fully and limits fully. If you have thoughts on any major encumbrances on doing this swiftly please let me know. THANK YOU.

[SOLVED] Generate specific range of Uniq ramdon from a main range

$
0
0
Hi,

yes, the post title Sounds weird (sorry)

Please i need expertise on how to create a sheet to generate Random numbers from 2 specific list
of a main list range of 36 Numbers. (List A = Specific 15 numbers, List B = The remaining Numbers from these 36)

Example :

-The Main List Range is from Number 01 to 36
-The Specific random list will be 15 Numbers of these 36

List A-.The Specific 15 Numbers are: 01,02,03,10,11,12,13,20,21,22,23,30,31,32,33
List B-.Remaining Numbers : 04,05,06,07,08,09,14,15,16,17,18,19,24,25,26,27,28,29,34,35,36

So

I need to generate ONE Unique Random Numbers of List A ( 01,02,03,10,11,12,13,20,21,22,23,30,31,32,33)
In Cell A1
In Cell A2
In Cell A3

And from List B, (04,05,06,07,08,09,14,15,16,17,18,19,24,25,26,27,28,29,34,35,36)
I need to do the samething In
Cell A4
Cell A5
Cell A6

A Dummy question.. (sorry, sometime i'm lil dum) : It's possible to have a 6 cells with random but Unique Digits?
(not repeated numbers between the 6 cell ??)

IMPORTANT NOTE :
If i came to this (ask you for help) Is because i already search about RANDOM and
tried to do it my self Using the RAND and RANDBETWEEN Formula (with no success :( )


Thank you so much !!


Best Regards from Miami

David

Product lookup and auto-replace cell with new value

$
0
0
Hey Everyone, I am putting together a fairly large workbook and need a bit of help with one aspect of it. It's an inventory tracking and ordering system, and it has a couple different pages for different features. One page is a master price list to be updated monthly with new prices etc.

I am looking to add a button that I could push, which look at every Sku# in a certain row, and find the corresponding entry on another page. They will be organized differently, so it will most likely need a lookup feature. There are several hundred products in the form, so it could maybe have a row range that it would look up each cell on the other page, then update the price from a couple cells over.

I have made a dummy version of it to upload on here. I appreciate any and all help, as i'm fairly new to excel. Thanks!!

-Jamie

sample.xlsx

Cascading user form combo boxes?

$
0
0
Hi all.
I have a workbook that I'm using fpr courses booking, it has a combo boxes so that I can select manager name, area and delegate name and click command button which puts all information onto the list. Its ok but I would like to use the userform instead of spread sheet to capture data.
I tried to copy the code from worksheet to userform but somethig is causing an error. I would appreciate your help in this matter.
Thank you in advance.

Loop through a subset of worksheets will not work

$
0
0
Greetings,

I'm trying to insert two rows in a subset of worksheets in a workbook by defining a range in a worksheet and loop through the worksheets in that range, but the code will only run on the active worksheet.
Code:

    Sub StatePIPData()
    Dim sheet_name As Range
    For Each sheet_name In Sheets("WS").Range("A:A")
        If sheet_name.Value = "" Then
            Exit For
        Else
            'Insert 2 rows for 2011 and 2012's data
            Range("A14").EntireRow.Insert
            Cells(14, 1) = Cells(15, 1) + 1
            Range("A14").EntireRow.Insert
            Cells(14, 1) = Cells(15, 1) + 1
            End If
        Next sheet_name
    End Sub

Any thoughts on how I could get this loop to work?

Thank you very much,

Make Sheet equal cell value + Date

$
0
0
Hello,

Is there a way I can make the sheet equal what is in "A2" and the date?

Say I have "John Smith" in "A2" I would want the tab to equal "John Smith 02 14"
Is this possible? Also I'd like for the file to be save as "John Smith 02 14"

Thank you for any help

How to find hidden macros in a VBA project?

$
0
0
I have got an Excelsheet wich was created from my predecessor. My task is to change some details in macros. But I cannot find not one line of code!
When I opened the file the first time I saw a macro, but then I clicked on some other sheets in the VBA and before I got a chance to copy the macro, it disappeared and there is no way I can find it again. I tried to open the file in another computer, but the macro is nowhere to be found.
The file has 50 worksheets and ThisWorkBook. On the "Properties" window for ThisWorkBook I can see that there is a password.

How can I find again the macro?

Thank you for any idea!
Viewing all 49833 articles
Browse latest View live