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

Macro on opening of any excel file - Mac Excel

$
0
0
I have some VBA in the ThisWorkbook module of Personal and it works perfectly on all PCs, but a few of my coworkers have Macs and tried to get it to work on their machines and can't get them to run. Any ideas?

Thanks!

Problem with bringing the right data to my VBA script

$
0
0
Hello everyone!

This is a great forum and many times I have founded a solution for my question via this web page without the need of even posting here. I´m quite new with VBA and I think this is very easy thing to do, but this time I didn't manage to solve the current problem on my own by reading and watching YouTube videos. The thing is I have now started to use VBA to analyse stocks and I have a specific "dashboard" for that purpose on Excel. For many purposes I need to use LN function and it´s working for me, but I didn't write it on my own, instead of that I used the recorder and now the function is in this form: "=LN(RC[-1]/R[-1]C[-1])". Well that´s fine since its working well, but here comes the thing I would need to fix.

If I have price data for "Stock A" for example in cells B8:52 and I want to use LN on that range, it looks like this on VBA for me: Range("C9:C52").Value = "=LN(RC[-1]/R[-1]C[-1])". How could I fix it so that my script would automatically check that on how many rows in B there is price data and use this LN for that range? I tried to use this:

With ActiveSheet
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
End With

To check on how many rows there is data in it´s showing me the right amount of rows, but I dont know how to connect this with my other parts.

English is not my first language so I hope you understood what I meant to say.

Thanks for help in advance and have a nice day

minimize a userform?

$
0
0
I'm trying to create command button on a modeless form as a simple way of minimizing the form (and another for restore).

I know there's a way to actually have Windows minimize and restore buttons on a form, but all that messing with Windows seems to be beyond my mental powers at the moment. So. is there a way to use xlMinimized with a form (or is it only for an application)?

Yes, I know I can just tell the command button to hide the form. But I want it to be only one click away, and on all worksheets. I thought minimizing it within the window might be a nice way to do this. The only other option I can think of is to have it resize the form down to nothing but the command buttons.

thanks...

(Solved) Clear userform after hitting "Submit"

$
0
0
I am VERY new VBA and Userforms so please be nice! :) I am trying to make a submit button that once you hit submit, it enters that data, and then clears the forms. Here is what I have. Again, please any help would be great
Private Sub CommandButton1_Click()
Dim rw As Integer
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
rw = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
ws.Cells(rw, 1) = CDate(Me.tbDate)
ws.Cells(rw, 2) = Me.tbTime
ws.Cells(rw, 3) = Me.tbShift
ws.Cells(rw, 4) = Me.tbLotNumber
ws.Cells(rw, 5) = Me.tbPartNumber
ws.Cells(rw, 6) = Me.tbTrailerName
ws.Cells(rw, 7) = Me.tbTrailerNumber
ws.Cells(rw, 8) = Me.tbAssocInitals
ws.Cells(rw, 8) = Me.tb1st
ws.Cells(rw, 9) = Me.tb60th
ws.Cells(rw, 10) = Me.tb120th
ws.Cells(rw, 11) = Me.tbQtyUnloadedFromTrailer
ws.Cells(rw, 12) = Me.tbLoadedFromFloorStock
ws.Cells(rw, 13) = Me.tbQtyMovedToFloorStock
ws.Cells(rw, 14) = Me.tbTrailerStatus
processcode
Clear Values
Me.tbDate.Value = ""
Me.tbShift.Value = ""
Me.tbLotNumber.Value = ""
Me.tbPartNumber.Value = ""
Me.tbTrailerName.Value = ""
Me.tbTrailerNumber.Value = ""
Me.tbAssocInitals.Value = ""
Me.tb1st.Value = ""
Me.tb60th.Value = ""
Me.tb120th.Value = ""
Me.tbQtyUnloadedFromTrailer.Value = ""
Me.tbLoadedFromFloorStock.Value = ""
Me.tbQtyMovedToFloorStock.Value = ""
Me.tbTrailerStatus.Value = ""

End Sub
Attached Files

vba WorksheetFunction Lookup(2,1/Countif(........))

$
0
0
Hello everyone,

Please take a look at this formula and see what's wrong:

x=Application.WorksheetFunction.LOOKUP(2,1/(WorksheetFunction.COUNTIF(Sheet8.Range("B3:B351"),"">"" & Sheet8.Range("B3:B351")=0),Sheet8.Range("B3:B351"))


Thank you.

Issue on filling grouped shapes

$
0
0
Dear gurus,

I've racked my brain for this seemingly easy issue without solution; so, I turn to you for help!:confused:

I've got a bunch of groups shapes (maps of some European states). Some countries consist of incontiguous territories, like France, Italy etc. I failed to apply such method to them while succeding in some other single shapes!
Formula:
Shapes.Range(Array("Italy")).Fill.ForeColor.RGB=RGb(255,255,0)

What's really weird is that a macro snippet is recorded on changing the "visible" attribute via Selection panel.

Pls refer to the attachment for details. Your help is much appreciated! Have a nice weekend! ;)
Attached Files

Command Button to strike

$
0
0
Hi,

I am trying to do a project and stuck at one of the place, I'm hoping that one of you expert will be able to help me out on the attached sheet.

What I'm looking for is :

1. If someone click on correction button then :
a) Input box to ask for the row number, once row number is entered then it strike to full row and remove it from the calculation in Column S:T and in the bottom Row 14
b) Also message box for 2 users to input their initial and put that with environ formula i.e. user name, date & time in Column AA & AB

The environ formula is currently running in column U and W so similar thing for the above.

really appreciate your help.

many thanks,
Attached Files

Unprotect ALL Checkboxes with VBA

$
0
0
Hello friends. I am working on a spreadsheet that has 2000+ checkboxes on it and a mess of formulas. I am trying to protect the sheet so that multiple people can use it without messing up the formulas but also be able to type in certain cells and use the checkboxes. My issue is that I cannot protect the sheet without unlocking the cell the checkbox is in and the checkbox itself. Currently, the only solution I have is to manually unlock each checkbox. I have VBA that unchecks them all at once, so I am wondering if there is VBA to unlock them all at once so I do not need to spend multiple hours unlocking them all. Thanks in advance!

Help with Dual Monitors

$
0
0
I have a computer running dual monitors. I can open 2 excel files, but when I run the Userform from one of them, all other Excel files disappear. Is there a way to run 2 different forms on 2 different monitors?

Data Matrix Barcode

$
0
0
This Query has also been posted here; stackoverflow-com/questions/60458914/data-matrix-barcode

First post so apologies if in the wrong place. (I've tried to search but was unable to find any solutions or suggestions)
I have inherited a mailing label created in an Excel sheet which pulls data from a second sheet. The label has (amongst other info) a QR code which was called thus chart.googleapis-com/chart?cht=qr
I need to change the QR barcode to a data matrix barcode, in a perfect world I would have been able to change "cht=qr" to give me what I need.
Can anyone point me in the direction of a solution? I have had to use - instead of . in the URLs to let me post, sorry.

How to adress any text and automatically exit the code?

$
0
0
Hi,

So, I was wondering how you can address any text in a cell and then exit the code.
Exit the code part is not hard, but I have no idea how to exit a cell that contains letters or signs like: "afdhfudshuifdshif" or "#&!/(¤&("!%¤(/")#0"

Thing is that my code will stop function if I get letters or signs in one of the cells in a certain range.

I thought that the code may be something like:

Code:

If Range("F2:Q2").Value = String
MsgBox "These cells can only contain numeric value" vbokonly "Textbox"
Exit Sub
End If

Any help is highly appreciated!

Sharepoint or web based database?

$
0
0
Hi all
I am reasonably ok with access databases and I have used VBA to communicate between Excel and Access on many occasions.
All was going fine until I was told our offshore team in India did not have access to our onshore servers. Therefore they could not use the excel/access application I built.

Then I found SharePoint 2013 and lists.
These are the same as 1 access data table but on line.

I have one SharePoint site which holds the Excel documents. This allows instant deployment of the latest versions and users use a link to open them.
I then have another SharePoint site which holds the lists. These have to be accessible to everyone and allow all to edit to allow data entry and modification.
This is not a problem as they are hidden from the search facility but the code in the excel vba communicates with the lists.

The only problem is we are now up to about 50000 records and the entry using ADO is getting slower.

Are there any other users out there who use SharePoint as a database?
What are my alternatives to make it faster?

Can you refer to a radio option button group to just get the value of the option selected

$
0
0
I have quite a few groups of radios and I'm wondering if there is a way to just refer to the group and get the option that is selected rather than checking the state of each radio.

[SOLVED] AUTOFILTER - Clearing

$
0
0
.
Is there a method of AUTOFILTER UNDO for the affected rows only ?

It appears from internet research that any method of clearing an AUTOFILTER involves all 1.4 million rows.

This is a macro I've tried, specifying a range of rows, but it takes the same amount of time as any other macro in making the hidden rows visible again :

Code:

Sub ReSetFilters()
    Dim lLastRow As Long
   
    With Application
        .Calculation = xlCalculationManual
        .EnableEvents = False
        .DisplayAlerts = False
        .ScreenUpdating = False
    End With
   
    'remove filter, not reuired any more
    Rows.EntireRow.Hidden = False
    ActiveSheet.Range("$B$1:$B$1003").AutoFilter  ' & lLastRow).AutoFilter 'repeat this line of code to remove the filter arrow dropdowns
    ActiveSheet.AutoFilterMode = False
   
    With Application
        .Calculation = xlCalculationAutomatic
        .EnableEvents = True
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With

End Sub


Any suggestions how to restrict the AUTOFILTER = False to the first 1,000 rows ?

Thanks.

Sort by cell colour for a year planner. Macrotastic?

$
0
0
Hi
I'm looking a for a little assistance. I have overhauled a shift roster that is managed by four people, to manage over 100 staff that move around a lot. There is a colour scheme for the different attendance or absences on the rota, but to make it easy for all to see who is due in, I have set up a macro as a trial that filters and sorts in colour order (there's conditional formatting for when a code is typed) and works well, however, I need to do that for 365 days, and I don't want to record 365 macro's.
I've attached the file and wondering if someone could advise how else to sort each day by colour?
Thanks in advance:-)
Rob
Attached Files

[SOLVED] Variables not available as required

$
0
0
I have been struggling for quite a while with variables.

I have mocked up a simple example of what I am trying to do on a more complex situation.

Please see attached file.

If I click the button on the sheet a userform (WhatActions) is displayed, if I select the check box beside “ONLY Add New Sheet” and then click “Continue” a variable “CreateNewSheet “ is populated with "NewSheet" then the userform is closed, this all works fine.

When I am returned to the code behind the button on the sheet the variable “CreateNewSheet is no longer populated.

I have placed Option Explicit & Public CreateNewSheet As String above each module in turn and tried to run it again but “CreateNewSheet is still not populated.

Can anyone get this to work with an explanation of what I should be doing and where?
Attached Files

need to clear contents of an excel file using command prompt or a batch file

$
0
0
need to clear contents of an excel file using command prompt or a batch file


for example clear contents of excel file
file 1
file 2
file 3

please help

Delete rows if

$
0
0
Hi,

I have a very long list

Newyork - Miami
Houston
Alabama - California
Canada
Mexico - Hawaii
Philadelphia - Atlanta
Washington DC
....

I would like a VB macro to delete all the rows with a dash - in it.
The result should look like this:

Houston
Canada
Washington DC

Appreciate any helps or advises!
VBisgreat

[SOLVED] Delete rows above a found keyword

$
0
0
I have the macro below to delete all rows above a found keyword. I am trying expand it to loop through all worksheets in a workbook, but have not had any luck. Any ideas? Thanks.

Code:

Sub DeleteRowsABove()
  Dim fRg As Range, ws As Worksheet
          Set fRg = Cells.Find(What:="Name", LookAt:=xlWhole)
        If fRg.Row <> 1 Then
            Range("A1", fRg.Offset(-1)).EntireRow.Delete
        Else
        End If
End Sub

Open list of URL in Internet Explorer

$
0
0
Hi

I have a list of URL in excel sheet ColumnA, I have to open each Url in Internet Explorer,copy the content of that page and paste it in active workbook in each sheet.

please anyone help me to loop through url and copy paste.
Viewing all 50054 articles
Browse latest View live