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

Getting Worksheet_Change(Byval) to work with Worksheet_calculate on two different sheets?

$
0
0
Hi,

I have a sheet that needs to utilize the following code:

Code:

Private Sub worksheet_calculate()
Application.EnableEvents = False
Dim Xrg As Range
Set Xrg = Range("C6:C7")
If Not Intersect(Xrg, Range("C6:C7")) Is Nothing Then
Goalseek
Application.EnableEvents = True
End If

End Sub

Then I have another sheet that is utilizing a code to transport values which is:

Code:

Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("$C$2:$C$7")) Is Nothing Then Exit Sub

Select Case Target.Address
' Address gets the cell name for the cell E.g. $B$4
    Case "$D$2"
        Worksheets("Calculations").Range("C7").Value = Worksheets("Values").Range("D2").Value
End Select

End Sub

So, I can't transport values to the sheet that has the first code I wrote. I only get an error stating the following:

Run time error 9
Subscript out of range

The code that transfer values work perfectly on other sheets that does not utilize the calculation code.

Anyone know the solution to the problem?

How to iterate lines of excel to save as pdf w/ updated filename

$
0
0
Hi guys,

Beginner here, so sorry for the mistakes. I hope that this is not too much trouble. My goal is to go through each line of code in Excel Workbook, and ExportAsFixedFormat each line as a separate, distinct pdf, with a constantly-changing cell value as filename. I have been at this for about a week and a half. At first, I was using Selection to take each Row I click on and print that as PDF, but this is too hard. I have seen code that does this for one pdf, but I need a lot of different pdfs. I am trying to take the entire spreadsheet and go line by line now, taking a pdf for each row, while also trying to print the labels at the top.

Here's an example:

Name Weight
Zeke 20
Dylan 14

And it would give, as two separate pdfs with filenames "Zeke" and "Dylan" respectively, with the content:

Name Weight
Zeke 20

And the other would be

Name Weight
Dylan 14

What I have so far is this (please do not run on your own stuff, as it currently will spam your printer to print blank pages).

Screen Shot 2020-01-19 at 12.25.43 PM.png

Right now, none of my code works (as mentioned, it prints a bunch of blank pages). I'm going to keep working on it, but I've sort of hit a wall. How do I PageSetup, or change what will be saved as a pdf, without having the macro just print the page out? I'm totally confused.

Some ideas I have is using a separate worksheet, that I can use the "set" function to make it only contain the TitleRow and CounterRow of Worksheets("Sheet1"). Maybe I can use a for loop given a range, to go through each line until lastRow, if Counter is responsible for this total mess.

Any help or guesses would be greatly appreciated, even to point me in a better direction. Thank you!

-Qiu Ye

searchable dropdown blocking blocking invalid data

$
0
0
Hi,

I created searchable dropdown in different columns. Currently I only use Application.Calculate in VBA. The dropdown is working but the macro should also alert If somebody fills invalid data into the active.cell. The alert should "Please select from valid data from dropdown list".

Can somebody help me to solve this problem?

Thank you,
BR,
Balazs

blocking warning message in excel

$
0
0
Hi,

I have a table in a protected Excel sheet. I am able to insert rows into the table but I always get warning message "The cell or chart you're trying to change is on a protected sheet. To make a change, unprotect the sheet. You might be requested to enter a password." Can I block this message by VBA code?

Thank you,

BR,
Balazs

Add conditional to VBA macro

$
0
0
Hi there. I want to apply a conditional to this macro:
Code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, c As Range, rngCol As Range
Set rngCol = Me.Range("Tabla[Entrada]:Tabla[Salida]")
Set rng = Application.Intersect(Target, rngCol)
If Not rng Is Nothing Then
Application.EnableEvents = False
For Each c In rng.Cells
If IsNumeric(c.Value) Then
If c.Value > 1 Then c.Value = c.Value / 100000000
End If
Next c
Application.EnableEvents = True
End If
End Sub

This code should not be applied if Tabla[Moneda] is BTC.

Thanks for your time.
Attached Files

Need to link a cell to a textbox (not a textbox to cell)

$
0
0
So I need help with some code to select the previous active selection (or) select a cell based on the formula in a cell-linked textbox that is actively selected.

Relevant code:
Code:

Cells(ActiveCell.Row, 1).Select                                              'selects cell with text'
ActiveSheet.Shapes.Range(ActiveCell.Value).Select                'selects textbox named the same string as the cell with text'
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 0, 255)      'colors active textbox'

Selects cell that active textbox is linked to or previous cell selection (which is one column left)


Thanks!

Image viewer with images control

$
0
0
Hello,

how can we make an image viewer
with in a frame1 and image controls

we like to go from out our database access to load where the ID from the person
and get all his image URLs and add them into the frame1 and create the image controls

like this image i created


i have tried to get all items from the listbox and works
[CODE]
For IntIndex = 0 To .ListCount - 1
LoadingImages (.Column(5, IntIndex))
Next
End With

but i can't manage to add seperate images ?
i get in the pictures the same one

Code:

Sub LoadingImages(m_url As String)
Dim imageurl As String
Dim fileName As String

imageurl = m_url
fileName = Environ("temp") & "" & Mid(imageurl, InStrRev(imageurl, "/") + 1)
   


    ' size of thumbnail
    Dim lngSide As Long
    lngSide = 50




    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets.Add


    Dim cht As Chart
    Set cht = ws.Shapes.AddChart(xlColumnClustered, _
        Width:=lngSide, _
        Height:=lngSide).Chart


    Application.DisplayAlerts = False
    ws.Delete
    Application.DisplayAlerts = True


    For i = 1 To 1
For j = 1 To 1
    k = i + (1 * j)
    Set cmdLots(k) = Frame2.Controls.Add("Forms.Image.1", "cmd1")
    With cmdLots(k)
        .Top = i * 6
        .Left = (j * 50) - 55 + 12
        .Height = 54
        .Width = 48
        .BackColor = RGB(50, 50, 0)
      .Picture = LoadPicture(fileName) 'get the same images ????
    .PictureSizeMode = fmPictureSizeModeZoom
    End With
Next j
Next i

its it also possible to add .picture like 8 add a row
and then start a new row if there are more pictures in the listbox
so it will be automatic order it
like on my image?

and if possible we like to add a click event aswell on every .picture we want to click on
to do some work

Thank you
hope someone can help me out

thank you
Attached Images

Applying Macro to more than 30 columns with collapsing rows fitting criteria

$
0
0
The code below is what I was using to repeat across the WorkSheet, but found I can only apply to 30 Columns, when I need 100 or more. How can I get the whole same macros to apply to all columns the same way?
Column A and B have text descriptors in them.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

' Column C,1
If Not Intersect(Target, Range("C1:C70")) Is Nothing Then

If Range("C29").Value = "" Then
Rows("30:30").EntireRow.Hidden = True
ElseIf Range("C29").Value = "Yes" Then
Rows("30:30").EntireRow.Hidden = False
ElseIf Range("C29").Value = "No" Then
Rows("30:30").EntireRow.Hidden = True
Else
Rows("30:30").EntireRow.Hidden = True
End If

If Range("C31").Value = "" Then
Rows("32:39").EntireRow.Hidden = True
ElseIf Range("C31").Value = "Yes" Then
Rows("32:39").EntireRow.Hidden = False
ElseIf Range("C31").Value = "No" Then
Rows("32:39").EntireRow.Hidden = True
Else
Rows("32:39").EntireRow.Hidden = True
End If

If Range("C40").Value = "" Then
Rows("41:43").EntireRow.Hidden = True
ElseIf Range("C40").Value = "Yes" Then
Rows("41:43").EntireRow.Hidden = False
ElseIf Range("C40").Value = "No" Then
Rows("41:43").EntireRow.Hidden = True
Else
Rows("41:43").EntireRow.Hidden = True
End If

If Range("C44").Value = "" Then
Rows("45:63").EntireRow.Hidden = True
ElseIf Range("C44").Value = "Yes" Then
Rows("45:63").EntireRow.Hidden = False
ElseIf Range("C44").Value = "No" Then
Rows("45:63").EntireRow.Hidden = True
Else
Rows("45:63").EntireRow.Hidden = True
End If

If Range("C64").Value = "" Then
Rows("65:68").EntireRow.Hidden = True
ElseIf Range("C64").Value = "Yes" Then
Rows("65:68").EntireRow.Hidden = False
ElseIf Range("C64").Value = "No" Then
Rows("65:68").EntireRow.Hidden = True
Else
Rows("65:68").EntireRow.Hidden = True
End If

If Range("C69").Value = "" Then
Rows("70:70").EntireRow.Hidden = True
ElseIf Range("C69").Value = "Yes" Then
Rows("70:70").EntireRow.Hidden = False
ElseIf Range("C69").Value = "No" Then
Rows("70:70").EntireRow.Hidden = True
Else
Rows("70:70").EntireRow.Hidden = True
End If
End If
End Sub
Attached Images

Issue running Macro with Pivot Table

$
0
0
I made a macro that works fine on my computer, but when my coworker tries to use it, she gets an error message when the macro tries to create a pivot table. It says Invalid Argument

Receiving error on this line:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R8673C35", Version:=6).CreatePivotTable TableDestination:= _
"", TableName:="PivotTable1", DefaultVersion:=6


Does anyone know how to edit the line so that it works on my coworker's computer?




Full Code listed below


Sub VoucherAudit()
'
' VoucherAudit Macro
'

'
Selection.AutoFilter
Cells.Select
Cells.EntireColumn.AutoFit
Range("I2").Select
ActiveSheet.Range("$A$1:$AH$16924").AutoFilter Field:=9, Operator:= _
xlFilterValues, Criteria2:=Array(0, "12/1/2019")
Range("A1:AH16924").Select
Range("I2").Activate
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
Range("C14").Select
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
ActiveWindow.ScrollColumn = 24
ActiveWindow.ScrollColumn = 25
ActiveWindow.ScrollColumn = 26
ActiveWindow.ScrollColumn = 27
ActiveWindow.ScrollColumn = 28
ActiveWindow.ScrollColumn = 29
ActiveWindow.ScrollColumn = 30
Range("AI1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "SI or PR"
Range("AI2").Select
ActiveCell.FormulaR1C1 = _
"=" & Chr(10) & "IF(LEFT(RC[-2],2)=""PR"",""Promotional""," & Chr(10) & "IF(LEFT(RC[-2],4)=""CSAT"",""Promotional""," & Chr(10) & "IF(LEFT(RC[-2],2)=""MK"",""Promotional""," & Chr(10) & "IF(LEFT(RC[-2],2)=""SI"",""Strategic Investment""," & Chr(10) & """Other""))))"
Range("AI2").Select
Selection.AutoFill Destination:=Range("AI2:AI8673")
Range("AI2:AI8673").Select
Range("AI2").Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R8673C35", Version:=6).CreatePivotTable TableDestination:= _
"", TableName:="PivotTable1", DefaultVersion:=6
With ActiveSheet.PivotTables("PivotTable1")
.ColumnGrand = True
.HasAutoFormat = True
.DisplayErrorString = False
.DisplayNullString = True
.EnableDrilldown = True
.ErrorString = ""
.MergeLabels = False
.NullString = ""
.PageFieldOrder = 2
.PageFieldWrapCount = 0
.PreserveFormatting = True
.RowGrand = True
.SaveData = True
.PrintTitles = False
.RepeatItemsOnEachPrintedPage = True
.TotalsAnnotation = False
.CompactRowIndent = 1
.InGridDropZones = False
.DisplayFieldCaptions = True
.DisplayMemberPropertyTooltips = False
.DisplayContextTooltips = True
.ShowDrillIndicators = True
.PrintDrillIndicators = False
.AllowMultipleFilters = False
.SortUsingCustomLists = True
.FieldListSortAscending = False
.ShowValuesRow = False
.CalculatedMembersInFilters = False
.RowAxisLayout xlCompactRow
End With
With ActiveSheet.PivotTables("PivotTable1").PivotCache
.RefreshOnFileOpen = False
.MissingItemsLimit = xlMissingItemsDefault
End With
ActiveSheet.PivotTables("PivotTable1").RepeatAllLabels xlRepeatLabels
With ActiveSheet.PivotTables("PivotTable1").PivotFields("SI or PR")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Geo")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Geo")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Voucher Amount"), "Sum of Voucher Amount", xlSum
ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.PivotTables("PivotTable1"), _
"Month (Order Date)", , xlTimeline).Slicers.Add ActiveSheet, , _
"Month (Order Date)", "Month (Order Date)", 240.75, 482.25, 262.5, 108
ActiveWorkbook.SlicerCaches("NativeTimeline_Month__Order_Date").TimelineState. _
SetFilterDateRange "12/1/2019", "12/31/2019"
End Sub

Validation of values in 3 columns based on set criterias

$
0
0
I'm very novice when it comes to VBA, and have been struggling setting some data validation and having it adjust the users input.

I have 3 columns, on columns I, J, and K with 36 rows where a user can input numbers. The value in column I, must fall between the values in J and K. The value in J must be less than or equal to K, and thus inversely, the value in K must be greater than J.

To add a 3rd twist, the difference between the values of K and J must not exceed 7,200.

The tricky part is it needs to work regardless of what column the user inputs values first.

I have this for loop with if statements that frequently crashes Excel. This code is in the Worksheet_Change event handler.

Code:

For Each Cell In Sheet1.Range("I24:I59")
    If IsEmpty(Cell) = False And IsEmpty(Cell.Offset(, 1)) = False And Cell < Cell.Offset(, 1) Then
        Cell.Offset(, 1).Value = Cell
        Exit Sub
    ElseIf IsEmpty(Cell) = False And IsEmpty(Cell.Offset(, 2)) = False And Cell > Cell.Offset(, 2) Then
        Cell.Offset(, 2).Value = Cell
        Exit Sub
    ElseIf IsEmpty(Cell) = False and IsEmpty(Cell.Offset(, 1)) = False And IsEmpty(Cell.Offset(, 2)) = False And Cell.Offset(, 2) - Cell.Offset(, 1) >= 7200 And Cell.Offset(, 2) - Cell >= 7200 Then
        Cell.Offset(, 1).Value = Cell.Offset(, 2) - 7199
        Cell.Value = Cell.Offset(, 2) - 7199
        Exit Sub
    ElseIf IsEmpty(Cell.Offset(, 1)) = False And IsEmpty(Cell.Offset(, 2)) = False And Cell.Offset(, 2) - Cell.Offset(, 1) >= 7200 Then
        Cell.Offset(, 1) = Cell.Offset(, 2) - 7199
        Exit Sub
    End If
    Next

The first 2 If statements work fine, it does what is intended by ensuring the value in column I always false between J and K and automatically adjusting them if the value in I changes.

Where I'm struggling is with the latter part of the code which is where the crashing is happening.

Any help would be greatly appreciated.

Change Syntax to Eliminate XLA File?

$
0
0
I am trying to recreate an excel file that performs various calculations using various functions. The original excel file has two accompanying .xla files.

I am wanting to eliminate the need for the xla files by copying functions directly into my excel file within a single module. However, there are various functions with Application.Run referencing the xla file (psychrometric functions.xla).

For example, this code in one of the xla files is referencing a function from the other xla file (psychrometric functions.xla).

Code:

w1 = Application.Run("'psychrometric functions.xla'!TdbTwbInput.TdbTwbtoGrains", Z, db1, wb1)
w2 = Application.Run("'psychrometric functions.xla'!TdbTwbInput.TdbTwbtoGrains", Z, db2, wb2)

Since I will now have the referenced functions (TbdTwbtoGrains) in my Excel file, how would I change the syntax?

My VBA knowledge is very limited, as well as my knowledge of the calculations. Any advice would be appreciated. Thanks!

Need vba code: import texfile to specfic column in a worksheet via vba

$
0
0
Hi everyone,

I want to do a backup and restore function in a worksheet.
I have a code which exports the data in column (CW) or column number 101 into a textfile, see below.

Code:

Public Sub ExportToTextFile(FName As String, _
 Sep As String, SelectionOnly As Boolean, _
 AppendData As Boolean)
Dim WholeLine As String
Dim FNum As Integer
Dim RowNdx As Long
Dim ColNdx As Integer
Dim StartRow As Long
Dim EndRow As Long
Dim StartCol As Integer
Dim EndCol As Integer
Dim CellValue As String
Application.ScreenUpdating = False
On Error GoTo EndMacro:
FNum = FreeFile
If SelectionOnly = True Then
 With Selection
 StartRow = .Cells(1).Row
 StartCol = .Cells(1).Column
 EndRow = .Cells(.Cells.Count).Row
 EndCol = .Cells(.Cells.Count).Column
 End With
Else
With Worksheets("Database3000").UsedRange
 StartRow = .Cells(1).Row
 StartCol = .Cells(101).Column
 EndRow = .Cells(.Cells.Count).Row
 EndCol = .Cells(101).Column
 End With
 
End If
If AppendData = True Then
 Open FName For Append Access Write As #FNum
Else
 Open FName For Output Access Write As #FNum
End If
For RowNdx = StartRow To EndRow
 WholeLine = ""
 For ColNdx = StartCol To EndCol
 If Cells(RowNdx, ColNdx).Value = "" Then
 CellValue = ""
 Else
 CellValue = Cells(RowNdx, ColNdx).Value
 End If
 WholeLine = WholeLine & CellValue & Sep
 Next ColNdx
 WholeLine = Left(WholeLine, Len(WholeLine) - Len(Sep))
 Print #FNum, WholeLine; "|"
 
Next RowNdx
EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True
Close #FNum
End Sub
Sub NotificationExport()
 Dim FileName As Variant
 Dim Sep As String
 
 FileName = "C:\Users\" & Environ("Username") & "\Desktop\Database3000\Notifications.txt"
 If FileName = False Then
 Exit Sub
 End If
 Sep = "|"
 If Sep = vbNullString Then
 Exit Sub
 End If
 Debug.Print "FileName: " & FileName, "Separator: " & Sep
 ExportToTextFile FName:=CStr(FileName), Sep:=CStr(Sep), _
 SelectionOnly:=False, AppendData:=False
 
End Sub

Now I was wondering if you could help me to export it back to the same column.
How can I achieve that?

Thanks a lot in advance for any help you could provide.

Macro to copy / paste from one tab into another then apply formula to all columns down

$
0
0
Hi all

I was wondering if someone can kindly assist me with a macro?

Step 1:
sheet name: E - Emp Detail

copy all employee ID #s from sheet "E - Emp Detail" from rows B3: to last active row

Step 2:
sheet name: MODEL

paste all the employee ID #s in row G23 down

THEN

i have formulas in "MODEL" sheet, from cell C22:CD22 ....row 22 has all the formulas, and is an example. I would like the macro to copy all the formulas from row 22 and apply to cell C23:CD last active row, using the formulas in row 22 above. keep in mind, column G is flat number that contains the employee ID.

I have attached a sample file, keep in mind, in the sample file, there are formulas where the sheets are not available - i am just providing this as a concept, so any help would be great, in how to write the code. thank you.

Page setup when selected items are sent to print Preview

$
0
0
Hi Guys

I would like some assistance with this problem please. I am a novice with VBA, so please try to keep it simple if you can.

I have a List box (ListboxSh) on sheet "Home", populated by a series of 'If' statements. (This part works fine.)

I then call a User form"PrintOptions" which holds some check boxes and 3 cmd. buttons, Customers, Admin, and Site. command buttons are coded as below to choose selected sheets from the list box and send them either to 'Print Preview or straight to print. (All this up to here works fine.)

This is the problem, each set of sheets is made up of the same sheets but is formatted differently. i.e. set1 i may be Portrait, Fit to pages wide 1 and zoom 80. it may have columns A to E Hidden =False, Whereas the sheets in set 2, although being the same sheets may be Landscape,Fit to pages wide 1 and Zoom 100. I may also like to Unhide some colums and maybe add some other page setup items.



The code below is what I am doing to get the selected sheets from my list box to my print preview / print screen.



My Question is what code do I need to implement the page setup changes and where in the code do I insert the new code. Please bear in mind that I may need to go backwards and forwards between the three sets of sheets.





vba]Private Sub CommandButton1_Click()

'''''''''''''''''''''''''''''''''''''''''''

' PRINT PREVIEW OF CUSTOMER SHEETS

''''''''''''''''''''''''''''''''''''''''''''



Application.ScreenUpdating = True

Unload Me



Dim i As Long, c As Long

Dim SheetArray() As String

With ActiveSheet.ListBoxSh

For i = 0 To .ListCount - 1

If .Selected(i) Then

ReDim Preserve SheetArray(c)

SheetArray(c) = .List(i)

c = c + 1

End If

Next i

Sheets(SheetArray()).PrintPreview



ScreenUpdating = True

End With

End Sub

applying macro to copy / paste from one sheet to another sheet

$
0
0
Hi all

similar but diff request.

can someone kindly / pls assist with a macro that will copy / paste data from one tab into another?

in sheet "BW LOAD", i have 5 columns where I would like a macro to copy / paste data

BW LOAD sheet:
column A = copy data from column D23: to last active row from sheet "model"

column B = copy value from "BW Load" sheet cell B3 and paste all the way to last active row, based on column A

column C = copy value from "BW Load" sheet cell C3 and paste all the way to last active row, based on column A

column D = copy data from column BM23: to last active row from sheet "model"

column E = copy value from "BW Load" sheet cell E3 and paste all the way to last active row, based on column A


can someone pls assist? thx you. i would like so that if i run the macro multiple times, it overwrites the existing data...thx you again!

Copy a Range to a New Worksheet Retaining Formulas and Formatting

$
0
0
Hello, I have inherited some code that will take a worksheet, filter on col A, pasting the data into a new worksheet, which is then saved as a new file. It works, however, it's just pasting formatting.. it's not retaining any formulas or columnwidth settings.. How can I update the copyto code below to retain the formatting, formulas and column? Thanks!


Code:

    Set wsData = Worksheets("PM_TL Evaluations - raw files")
    Set wsCrit = Worksheets.Add
   
 
    LastRow = wsData.Range("A" & Rows.Count).End(xlUp).Row
   
    wsData.Range("A1:A" & LastRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wsCrit.Range("A1"), Unique:=True
   
    Set rngCrit = wsCrit.Range("A2")
    While rngCrit.Value <> ""
        Set wsNew = Worksheets.Add
        wsData.Range("A1:L" & LastRow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rngCrit.Offset(-1).Resize(2), CopyToRange:=wsNew.Range("A1"), Unique:=False
        wsNew.Name = "PM_TL Evaluation" 'rngCrit
        wsNew.Copy
        Set wbNew = ActiveWorkbook
        wbNew.SaveAs ThisWorkbook.Path & "\" & rngCrit & " - 2019 PM-TL Evaluations"
        wbNew.Close SaveChanges:=True
        Application.DisplayAlerts = False
        wsNew.Delete
        rngCrit.EntireRow.Delete
        Set rngCrit = wsCrit.Range("A2")
    Wend
   
    wsCrit.Delete
    Application.DisplayAlerts = True

Macro for aging

$
0
0
Attached is the file I have calculated the aging with formulas.
It is possible to get that with the help of macro instead of formulas? So, starting F to column J, can it be calculated with macro? Please help!
Attached Files

[SOLVED] Looking for some VBA programming help with a search function

$
0
0
I am completely new to VBA and I don't really know where to even begin on this. Basically what I am trying to accomplish is the workbook I am working on has 3 columns and a search cell function. In the search cell would be a manual or scanned input to search Column 1 for the value and highlight the cell in Column 1 if there is a match(No highlight if no match). The first column has a specific number in each column. What I would like to happen is when the manual/scanned input is put into the search box, for it to automatically paste the input into Column 2 and also highlight the column 2 box IF the value is matched to Column 1(Do nothing if it does not). (Column 3 is a match verification if Column 1 Row x matches Column 2 Row x.) I attached 4 files showing the progression of what I would like to accomplish.

Thank you in advance for any guidance!

Macro - Copy a Tab and Save in New File plus Sort

$
0
0
So about a week a ago I requested help with a VBA code to take the Pay Managment tab in the attached file and save it in a new file and also save them as values. In addition to this code I would like, if possible, to sort it once it exports it to the new file. This was the code that was written by mumps 1. It works beautifully except now I would like the NAME column to be sorted alphabetically when it exports it to a new sheet.

Thank you.

Code:

Sub CreateNewFile()
    Application.ScreenUpdating = False
    Sheets("Pay Mgmt Summary").Copy
    ActiveSheet.UsedRange.Cells.Value = ActiveSheet.UsedRange.Cells.Value
    Application.ScreenUpdating = True
End Sub

Attached Files

Copy & Pasting formulas from one page to another via VBA

$
0
0
Team,

I am trying to write a VBA that uses 3 separate formulas across 2 sheets. The 2 sheets contain many variables that are pasted in from a Quickbooks export file. I would like to save the three formulas on a third page and then cut and paste them into the appropriate areas after pasting my exported data. Unfortunately when I currently do this I either get a paste error from VBA, or the formulas have changed from being cut and paste.

Please Help!
Viewing all 49820 articles
Browse latest View live