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

VB Code to find Unique Numbers

$
0
0
Hello:

Please refer to attached sheet.

I have numbers in column A thru G.

I need unique numbers from this list in column J as shown.
Please let me know if any qustions.

Thanks

Riz
Attached Files

VB code for multiple users and log ins - Just wont work!!!

$
0
0
hi All,

Simple issue that for love nor money I cant get to work.

I have a Excel spread sheet running lots of macro's / VB code.

I have a user form that activiets when the work book is open, that currently people just type in their name (so I can monitor who opens the wokrbook and when)

I have now had the request that People select there name from a drop down box and input their own passowrd - to stop others from just typing in their name.

I have created a list of user names in Sheet 16, Column A and named it 'users'
I have asked for passwords and in column B put thier passwords.

Simple I want when they select their name from combobox 1, that when they type their password in text box 1 (below) it grants access.
For some reason i cant get the 1st combo box to recognise in the VB code to look up the 'users'
Then obvioulsy, when combox 1 <> "Jack" then textbox 1 <> "password" else go to end;

Sunday evening may be but I cant get the code in the right place or scribe it right

Any help?

Delete workbooks with specific prefix in its name

$
0
0
Hi friends,

I have a small question, is it possible to close and delete open workbook with some specific prefix in the file name.

Suppose i have 4 open workbooks, say Workbook 1, Data 2, Data 3 (Number will keep on changing), RawData 4

Now from Workbook 1, i want to close and delete the second and third workbook with file name prefix "Data" (The numerical values will keep on changing so i cant give the full workbook name to close and delete).

Please let me know if it is possible and how.


Thanks & Regards

VB code for Linking combo box's

$
0
0
Hi All,

Am having some real trouble with combo box's - though I shouldnt be!!!

Simple one im sure:

Combo box 1 grabs data from a list of Names in sheet 1 named "Engineers"
Combo box 2 needs to display a list of data based on the selected name of combo box 2.

For example Combo box 1 = "Paul"
Combo Box 2 = " Project 1, project 2"

Combo box 1 = "Luke"
Combo Box 2 = "project 3, project 4"

FYI Projects are listed in separate columns based on who they belong to.

So I need combo box 1 to display all engineers names,
Combo box 2 to find the column that shows the projects associated with that engineers name

Any suggesttions

Best regards

Click to get SUM of two cells

$
0
0
Hello and thanks in advance for your help.

Here is my dilemma:
Column C contains a start time
Column D contains an end time

I would like for column E to display the difference between column C and column D only when you click on a cell on column E.

Attached is the file.

What are Dim, Modifier and Sub ( ) vs Private Sub ( )?

$
0
0
Hi,

I know above are the things explailed all over the web and one does not need much google to find these.

But nobody has explained these things for a layman who is new to programing world.

I have made some good macros but still I don't know what are following things;

1- What the _ell is the dim word? What if it were never born?

2- Why do we call them modifiers?

3- Why some people prefer to write Private Sub Name() instead of simply writing Sub Name()

Please explain above things to a layman.

(I am not;) a lay man)

Using Vlookup with Items or names that are the same

$
0
0
With information from the following thread:
HTML Code:

http://www.excelforum.com/excel-programming-vba-macros/978346-vlookup-in-vba.html
, and the attached workbook, the vlookup works, but only if all items are unique. I can put a unique number in column A but don't understand vba enough change code to read from column A.

Any assistance is appreciated.

Thank you in advance,

BigDawg15
Attached Files

Macro to be available in all workbooks.

$
0
0
Hi, I have a macro I use in many different workbooks.

Is there a way to have the macro available in all newly opened workbooks?

Macro To Show Current Workbook Only

$
0
0
Dear Excel Community

The attached spread sheet has a macro already created that is now functioning OK.

Can someone advise what do I need to modify so that the macro only appears for the current work book.

I notice that if I open several different workbooks and click on macro button, the CopyData appears in this also.

If I am wrong in my logic please let me know as I am still trying to grasp VBA

Thanks in advance

Drop down calendar

$
0
0
Hello....

Does anybody have a developed Macro for a calendar that opens when a cell is selected?

Thanks much

Please explain this macro for cutting rows

$
0
0
Could someone please explain the concepts and each piece of the macro below. In as much detail as possible!! A couple specific questions: 1) What is Const? 2) What are the pieces of the "find" 3) What does "If Not is nothing" mean? And many more!!




Code:

Sub Purchasing()
Const fWhat As String = "purchasing"
Dim R As Range, fAdr As String, nR As Long, cutRng As Range, Ar As Range
With Sheets("Sheet1")
    Set R = .Range("A:A").Find(fWhat, [A1], xlFormulas, xlPart, , , False)
    If Not R Is Nothing Then
        fAdr = R.Address
        Set cutRng = R.Offset(-1, 0).Resize(4, .UsedRange.Columns.Count)
        Do
            Set R = .Range("A:A").FindNext(R)
            If R Is Nothing Then Exit Do
            If R.Address = fAdr Then Exit Do
            Set cutRng = Union(cutRng, R.Offset(-1, 0).Resize(4, .UsedRange.Columns.Count))
        Loop
    End If
    If Not cutRng Is Nothing Then
        nR = 1
        For Each Ar In cutRng.Areas
            Ar.Cut Destination:=Sheets(.Index + 1).Range("A" & nR)
            nR = Sheets(.Index + 1).Range("A" & Rows.Count).End(xlUp).Row + 1
        Next Ar
    End If
End With

[SOLVED] VBA to auto update when opening a workbook

$
0
0
Hi,

When I run the below code on certain workbooks it stops the macro and asks if I would like to update the workbook, how can I make it so it automatically selects yes or no within this formula.

Once again thanks in advance for the help.


Code:

Option Explicit

Sub Nearly()

 
  Dim wbTarget            As Workbook 'workbook where the data is to be pasted
  Dim wbThis              As Workbook 'workbook from where the data is to copied
  Dim strName            As String  'target workbook
  Dim cn As String
   
  'set to the current active workbook (the source book)
 
  Set wbThis = ActiveWorkbook
   
  'open a workbook that has same name as the sheet name
  Set wbTarget = Workbooks.Open("C:\Users\Daisy\Desktop\Sheet1.xlsm") 'Put your path in the space noted
   
  'select cell A1 on the target book
  wbTarget.Sheets("test").Range("A1").Select
   
  'clear existing values form target book
  wbTarget.Sheets("test").Range("A1").EntireColumn.ClearContents

  'activate the source book
  wbThis.Activate
   
  'clear any thing on clipboard to maximize available memory
  Application.CutCopyMode = False
   
  'copy the range from source book
  wbThis.ActiveSheet.Range("A2:D13").copy
   
  'paste the data on the target book ( for just values PasteSpecial xlValues )
  wbTarget.Sheets("test").Cells(10, Columns.Count).End(xlToLeft).Offset(, 2).PasteSpecial xlPasteAll
   
  'clear any thing on clipboard to maximize available memory
  Application.CutCopyMode = False
   
  'save the target book
  wbTarget.Save
   
  'IF close the workbook,change activate to close if you would like the pasted work book to close when complete
 
  If wbTarget.Name <> "Sheet1" Then
wbTarget.Close
End If
 


  'activate the source book again
  wbThis.Activate
   
  'clear memory
  Set wbTarget = Nothing
  Set wbThis = Nothing
   
End Sub

Refer to specific workbook.sheet

$
0
0
Hi,
Is it possible to refer to specific sheet inside of worksheet using macros, I need
- open fileA
- paste content of fileA into fileB, but paste into specific Sheet, depending of variable, all Sheets in fileB already predefined,
e.g. if current month = 'January' then copy into 'Jan'
elseif current month = 'February' then copy into 'Feb' etc...


Thansk for your help.
Mario

copying range based on date

$
0
0
Hello. I have copied a file with instructions. The "data" sheet is actually it's own workbook, as is the "parent" tab. I want the master file to look at ALL open workbooks, look in row A3 and match that date with the date in "parent" tab and then copy the range (highlighted in yellow) in the "data" workbook into the yellow row. These cell locations will NEVER change. Thanks. Spreadsheet attached. Please explain code as well.
Attached Files

[SOLVED] Marco to sort cells

$
0
0
I am trying to add a macro that will sort everything by what is in column A (not the first row though) and then have it expand the selection to the entire row and sort it. so basicly it would do the same as me clicking sort and filter and then selecting sort largest to smallest and then selecting yes to expand the selection. I have found some that sort only column A but nothing that changes it all. Thanks!

Collapse multiple rows of data for a common item and delete redundant data

$
0
0
I have a lot of data that comes to me like the attached example. :eek: I am trying to find a quick way to collapse all of the data into one row.

Figuring out a "quick" way is taking me a long time and I'm not having much success! :(

  • There are multiple rows about Thing1;
  • In some rows there is data in ColumnX in other rows there is data in ColumnY, ColumnZ, etc.
  • The information in the columns is not in any order, not always ColumnX then Y then Z.
  • It is important that the information stay in the column where it is in the original file.
  • Thing1, Thing2, etc. may have different numbers of rows depending upon how many data points there are.
  • Multipile columns of fully-populated duplicate data exist for instances of Thing1.
  • I need to keep one set of that information with the row for Thing1.


There are generally not columns that have multiple values for Thing1 in the the same column over multiple rows (not saying there never will be, but that would be extremely rare).

See attached example.
I have added shading to distinguish one Thing from another, but don't need there to be any formatting in the end result.

I am posting in this forum because I believe VBA/Macro would be best for solving it. There are quite a few similar posts, but I am not finding anything that is quite like this... if there is, I'll be happy to refer to another thread!

Thank you for any assistance you are able to provide. :)

How to read a named cell from another worksheet

$
0
0
How would I go about reading a named cell from another worksheet with out selecting it.
I know it should be easy

thanks

Microsoft Excel Query report , Sum prior yr Depr by date in Seperate column

$
0
0
I am learning MS query in excel, have created this report, cannot find the solution how to resolve it,
have a column with all the depr , want to sum depr by dates, is this possible in excel query , I have tried every thing , or I export this in excel than I can add the formula in cell

for example 1,2,3 column Date, AmountDepr , Prior Yr Amount

Date AmountDepr Prior Yr Amomut

10/1/2012 2453.85 sum all these amount by dated from OCT to Feb in formula,
11/1/2012 2453.85
12/1/2012 395.78
1/1/2013 327.18
2/1/2013 158.31


please some one help me , if this is possible in excel query or excel


any help will be appreciated. you guys are so expert and always helped me in the past.

Highlight Data Based on Data in Another Column

$
0
0
How can I highlight data based on another cell in the same row?

Ex. I only want to Select data in Column C only if Column B = Rm2


A B C D
1 Bob Rm1 x 0
2 Jack Rm1 x 0
3 Dean Rm2 n 0
4 John Rm2 n 0
5 Barb Rm3 x 0

VBA how to convert a range to a table in excel 2010

$
0
0
I am relatively new to VBA and am trying to convert a range of data to a table in the same sheet. I receive the following message when I try to run the code as shown below:

"The worksheet for the table data must be the same sheet as the table being created." The code stops on the third line of the code.

Sheets("Data Forwards").Select
ActiveSheet.Range("$A$1:$U$1000").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$U$1000"), , xlYes).Name = _
"Table1"
ActiveSheet.Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleMedium2"

I can see that the range is highlighted in the sheet before the code breaks. Any advice would be greatly appreciated.
Viewing all 50038 articles
Browse latest View live