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

How to check last user modify the vba code

$
0
0
Hi All,

Can somebody help me to know how we will get the information about who have modified the vba code lastly or a trail of all the modifications done?

Is their any way to record this information in same excel file with password protect the information so no one can change that information apart from the 1st writer?

I mean the fields where this information available is password protect and the password is not visible in the coding also. So in future if some one have the password to change the codes still he will not get the password to modify specific fields where the information is available of last modification.

Thanks for the help in advance.

Macro to find duplicates, concatenate cells, then delete old duplicates (2)

$
0
0
Hi...i have follow up questions on the post above (initiate by givemepuppies).
I would like to apply this code to multiple columns by a set of 2 (pls see attachment).
Can this be done?

Code:

Sub merge_duplicates()
 
Dim count, count_1, found_str
count = 2
Do Until Range("A" & count) = ""
    found_str = 0
    For count_1 = 1 To count - 1
        If InStr(1, Range("A" & count), Range("A" & count_1)) > 0 Then
            Range("B" & count_1) = Range("B" & count_1) & ", " & Range("B" & count)
            'Range("C" & count_1) = Range("C" & count_1) + Range("C" & count)
            found_str = 1
        End If
    Next
    If found_str = 1 Then
        Rows(count).Delete
    Else
        count = count + 1
    End If
Loop
End Sub

Attached Files

Monte Carlo in Excel

$
0
0
I need to do Monte carlo simulation in excel. I have a fixed concentration value(0.0006) and value of flux 24 with a range of 20-200. We are multiplying the concentration value with flux value to calculate the flow. So i need to know the error using uniform calculation. I saw the value for flow given is 0.0144+/-0.032 for the given concentration and flux value . I cannot redo this calculation. Please help me. :)

Run Macro over folder of excel files

$
0
0
I have a folder of identical excel files that act as a forms. I need to run a macro over the folder that extracts the same data from *** the files and puts them into a database.

In the new workbook each row will be a form/file from the folder and the columns will have the information from the identical forms.

Any help much appreciated.

Thanks

Mike

Save specific worksheet as separate workbook

$
0
0
Hi,

I am trying to save a specific worksheet called "Status" as a separate workbook (xlsx) in a specific folder. In the new workbook all filled in cells should be formated as values so there are no formulas.

Can you please provide me with a VBA code which solves this issue?

Thank you so much in advance.

Macro to merge PDF files

$
0
0
Hi Champs,

I have many pdfs (acrobat reader) files in a folder.

i need a macro to merge all files in to one .

Pls help

Macro Button error ("user-defined type not defined")

$
0
0
Hi All,
I'm a long time reader of the forum and now my first post. I generally find the solution to my macro requirements by searching the internet, this one has me looking for your help.

I have a workbook with several sheets that I use on a daily basis, one sheet for each day of the week Monday To Sunday. Each sheet has several Macros . Sunday the workbook is saved, copied and the copy is renamed.
The problem I have is, after the name change I then have to reassign macros to the buttons which really defeats the porpoise of having the buttons. The buttons where created using forms control and are strategically scattered throughout the sheets. The workbook name is "Daily Diary week Ending 15-05-16" . The workbook name change is the date
I'm not very good at creating my own macros however I'm getting ok at changing others to suit my individual requirements. I considered recording a macro but it would be quite a long macro.

Any ideas would be greatly appreciated.
Thanks in advance

Problems with file director on mac

$
0
0
Hello, i'm getting an error on the last line of my code (Workbooks.Open...), is the error on the file directory or on the code? Thank you!!

dit_dt1_base cell value is = /Users/myname/Desktop
arq_dt1_base cell value is = /dtbase1.xlsx

Code:

Sub testing_macro1()

Dim dir_dt1 As String
Dim arq_dt1 As String

dir_dt1 = Range("dir_dt1_base").Value
arq_dt1 = Range("arq_dt1_base").Value

Workbooks.Open (dir_dt1 & arq_dt1), False

End Sub


Merge text in cell into one.

$
0
0
Hi I need help to make a macro which in column C merge the text in the cells. There criteria is that it have to merge the text in column C until the next date displayed in column A. So the result could be like below.- I need use on a sheet with very many rows so speed is little important also.

Please have a look also at the test sheet.

1 02.01.2013 textvbkkkakskks -7.506.199,97 NTRF
testssssss
TS CHLAND GMBH 000
EZV9003200200005
Reference 9003200200005
2 02.01.2013 textssssss 25,13 NTRF
goooo28222
GMBH U. CO KG 000
471530250000EUR
Reference NONREF
This is how it looks and i want following result.
1 02.01.2013 textvbkkkakskks,testssssss,TS CHLAND GMBH 000,EZV9003200200005,Reference 9003200200005 -7.506.199,97 NTRF
Maybe with a comma between the text and it change to the next when the next date come in column A.

Please have a look thanks

Sincerely
Abjac
Attached Files

search cells after finding a range

$
0
0
Hi all

I am attempting to find Location using the Set rangFound line of code.
Then need to offset so I can being my search of a specific value (PTOut) which is 2 txt fields from a userform that is put together earlier.
The part I keep getting an error {1004 Application-defined or object-defines error} in is where the arrows are pointing (i believe that is where).

Once I offset, I need to search through the cells in the next 10-20 rows, in that column, looking for the cell value that matches the value in PTOut.
I do not believe I can use rngFound <> to PTOut, as rngFound is a range and PTOut is text. I tried to use rngFound.Value, but that gave me the same error.

Code:

Dim myCell As Range, rngFound As Range
   
    Set rngFound = Worksheets("Overview").Range("a1:zz10000").Find(What:=Location, LookIn:=xlValues, LookAt:=xlWhole, _
        SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
   
       
     
   
        If Not rngFound Is Nothing Then
            Set rngFound = rngFound.Offset(2, 0)

            While rngFound <> PTOut                          <<<<<<<-----------  this is where I believe I am having issues.....
              Set rngFound = rngFound.Offset(1, 0)
            Wend

Thanks

Selective Emails from Excel

$
0
0
Hello all

I would like to mail to multiple emails addresses from Excel when I create an X in column A. I'm looking at column B for review date and column F for Survey. When I click the X it should email a message and a PDF survey attachment located in Survey worksheet.

File here: https://www.dropbox.com/s/imcxd9o0qf...orum.xlsm?dl=0

Is this possible? If not can you suggest a work around?

Thank you Jill

How to insert commas instead of blank in all txt files?

$
0
0
Dear all,

how can I create a macros that changes spaces to commas in all lines in all txt files and overwites the original file?
For example, I need to change this line:
03/26/2008 09:03:00 32.8 32.8 32.8 32.8 50
into this:
03/26/2008,09:03:00,32.8,32.8,32.8,32.8,50

Thank you very much!

Create Custom Menu to wrap Selected Cells in IFERROR formula

$
0
0
Hi,

I want to create a custom menu option when I highlight cells and right click. The menu opton will say "Wrap Selected Cells in IFERROR"

When I select this option, the macro will basically wrap all cells that are highlighted with IFERROR and the IFERROR value returned should be a blank ("")

Can anyone help me do this in a simple way? I want this always available so I guess it should go as a module in PERSONAL.xlsb?

Thanks!

Auto delete all previous version of the worksheet when exiting updated sheet

$
0
0
I have used code to save the worksheet to add the date and time on save function. I am now trying to delete the previous versions automatically when either saving or exiting the latest worksheet. Can you assist please?

Many Thanks

Robbosan

If Not Intersect(Target, Range("AD:AD")) Is Nothing Then,,,,VLOOKUP??

$
0
0
Hi

I forgive my ignorance I am new to VBA and have ben trying to cut and paste various bits of code together to achieve my goal

end goal =

double click a cell in a column from which an embedded file (outlook message) is opened

The column contains 100's of entries but these boil down to 5 variants (each variant has its own email)

I can get the code to open up a single object but not to open up the object related to the value in the column

any help would be much appreciated
Thanks



Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Dim Object99 As String

Object99 = Application.WorksheetFunction.VLookup(Objective, Worksheets("email").Range("b:c"), 2, False)
'MsgBox Object1



If Not Intersect(Target, Range("AD:AD")) Is Nothing Then

Application.ScreenUpdating = False

Sheets("email").OLEObjects("Object99").Verb

Me.Activate

Application.ScreenUpdating = True

Cancel = True

End If

End Sub

Pivot Table refresh

$
0
0
Hi All,

I have a pivot table that data will automatically will be added to it through a username i.e users fill in a form through a userform and data will be added to the Pivot Table. I have used the following code to update the table automatically but I am getting 'run time error 1004' and showing below message box.

1004 error.jpg

Code:

Sub RefreshPivotTable()

Dim xTable As PivotTable

For Each xTable In Application.Worksheets("Seasonality Chart").PivotTables
    xTable.RefreshTable
Next

End Sub

Code execution is stopping Query from refreshing

$
0
0
I have some code that opens a file and refreshes 5 SQL queries across 5 sheets that are embedded in the file.

I am experiencing a problem where the query is running and 4 of the sheets are updating but the sheets that is selected when the file is opened fail to refresh.

If I put stops in the code just before I copy the data in the sheet, the query catches up and I can see the records being popluated down the sheet but if I leave the code to run, it's like it doesn't get chance to 'put' the records in the sheet and effectively returns no data.

Code:

Sub QueryData()

Dim wsQuerySheet As Worksheet
Dim wsDashboardSheet As Worksheet

Dim rngCheck As Range
Dim rngCopyFrom As Range
Dim rngCopyTo As Range
Dim rngFormulas As Range
Dim rngClear As Range

Dim lngOldRowCount As Long
Dim lngRowCount As Long

Set wbDashBoard = ActiveWorkbook

ShowRefresh

Set wbQueryData = Workbooks.Open(ActiveWorkbook.Path & "\CreditControlQuery.xlsb")

wbQueryData.RefreshAll

boolRefresh = False

Do Until boolRefresh = True
  Set rngCheck = wbQueryData.Sheets("Credit Controller").Range("A1048576").End(xlUp)
 
  If rngCheck.Row = 1 Then
      boolRefresh = False
      Else
      boolRefresh = True
      Sheets("Credit Controller").Activate
      Application.Wait Now + TimeValue("00:00:05")
  End If

  If boolRefresh = True Then
      Set rngCheck = wbQueryData.Sheets("Accounts on Stop").Range("A1048576").End(xlUp)
     
      If rngCheck.Row = 1 Then
        boolRefresh = False
        Else
        boolRefresh = True
        Sheets("Accounts on Stop").Activate
        Application.Wait Now + TimeValue("00:00:05")
      End If
 
      If boolRefresh = True Then
        Set rngCheck = wbQueryData.Sheets("Transactions").Range("A1048576").End(xlUp)
       
        If rngCheck.Row = 1 Then
            boolRefresh = False
            Else
            boolRefresh = True
            Sheets("Transactions").Activate
            Application.Wait Now + TimeValue("00:00:05")
        End If
       
        If boolRefresh = True Then
            Set rngCheck = wbQueryData.Sheets("Chased History").Range("A1048576").End(xlUp)
           
            If rngCheck.Row = 1 Then
              boolRefresh = False
              Else
              boolRefresh = True
              Sheets("Chased History").Activate
              Application.Wait Now + TimeValue("00:00:05")
            End If
           
            If boolRefresh = True Then
              Set rngCheck = wbQueryData.Sheets("Aged Debtors").Range("A1048576").End(xlUp)
             
              If rngCheck.Row = 1 Then
                  boolRefresh = False
                  Else
                  boolRefresh = True
                  Sheets("Aged Debtors").Activate
                  Application.Wait Now + TimeValue("00:00:05")
              End If
              Else
            End If
           
            Else
        End If
       
        Else
      End If
     
      Else
  End If

Loop

Set rngCheck = Nothing

Sheets("Credit Controller").Activate

Application.Wait Now + TimeValue("00:00:30")

Application.Calculation = xlManual

Application.EnableEvents = False

Set wsDashboardSheet = wbDashBoard.Sheets("Credit Control Query")

Set rngClear = wsDashboardSheet.Range("CCQ_CCStart").Offset(1, 0)

Range(rngClear, rngClear.Offset(150000, 0)).EntireRow.ClearContents

Set rngClear = Nothing

wbDashBoard.Sheets("Credit Control Query").Calculate

'Get CC Query data & copy fromulas down
Set wsQuerySheet = wbQueryData.Sheets("Credit Controller")

lngOldRowCount = wsDashboardSheet.Range("CCQ_CCCount")

Set rngCopyFrom = wsQuerySheet.Range("A2")

'Col A
Set rngCopyFrom = Range(rngCopyFrom, rngCopyFrom.End(xlDown))

rngCopyFrom.Copy 'THIS IS WHERE IT COPIES THE DATA FROM BUT THE TABLE IS EMPTY

I have tried to use the wait command but this seems to stop anythign from happening and the data doesn't get put in the sheet so the code to try and copy the data effectively copies nothing.

Is there a way to tell Excel to wait without completely downing tools and let the query refresh?


Thanks

VBA Newbie

$
0
0
hi there,


i am a newbie to VBA world, i would like to create a bond amortization sheet using macro and I dont know how to start coding for it, could any of you help me in this pls pls pls. i would appreciate it.

thanks

Collect data from many sheets and place in another sheet

$
0
0
Hi Guys

I have a sheet that contains machine settings that need updating from time to time. Is there a way of collecting data (from the same 3 cells in each sheets) and placing it in another sheet?

Thanks for looking

Ross

Problems refreshing the tables not enough memory!!

$
0
0
Hi,
I have 157 pivot tables that using 5 data files all the same file. I have a problem when I try to refresh the tables , I receive a message saying that I don't have engouh resources and I need to change the range, but I don't want to change the range or file. Is there a way you can free the memory after refreshing the pivot table.

Thank you
Viewing all 50057 articles
Browse latest View live