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

Fuzzy string matching for people names

$
0
0
Hi

I need a VBA Function that should match "Yaqoob Alkundi" with "Yaqoob Alkundi" OR "Yaaqoob A Kundi" OR " Yaqub Al-Kundhi"

All the above strings will be a variable .

Hope my short question makes sense.

Best Regards
Imran Bhatti

Email basis ID mentioned in Excel Sheet and information as Attachment

$
0
0
Greetings,

I want to send email basis Name in Column "A" and Email ID in Column "B" and attachment information from Column C to H.

Also in the body of the mail i want to mention the name of the sender with some standard message.

I have tried rondebruin but could not execute. Request expertise adivce.

PS. Information from Column C to H sholud be as attachment not to be copied to mail body.
Attached Files

IF Statement In VBA

$
0
0
Hi Guys And Gals,

I have an IF Statement query which has been puzzling me for a few hours today. I have managed to write and IF Statement consisting of 'And', 'Or' and 'XOR' in the formula bar of Excel and it works as it should do. However I would like to put this into VBA code which is proving to be a little trickier. Wonder if anyone could shine any light onto my puzzle.

The statement which I have written is : =IF(OR(AND(A2<>""),AND(XOR(C2<>""),AND(B2<>"")),AND(C2<>""),AND(D2<>"")),TRUE,FALSE)

Many thanks in advance

KIZA

Want to update stock sheet as and when i enter product code in invoice sheet

$
0
0
Hi everyone.

I am new to excel and have been attempting to learn it myself.
'
I have Invoice in Sheet1
and I have stock in Sheet2 where i record my stock

I was looking for something where I could link my invoice and stock sheet. So when i enter the product code and quantity in invoice sheet then it automatically reduces from the stock sheet.

Anyone who could help me please?

I am stuck in this since long. Please help

[SOLVED] Cleaning a range

$
0
0
Hello Experts,
I am trying to go to the last row of column G and clear 13 rows and 5 columns (Column G through K and 13 rows including last ) using the following code and I am getting runtime error.

[code]Range("G4").End(xlDown).Resize(ActiveCell.Offset(-12, 6)).ClearContents[code]

Please advise.

Best Regards/VKS

Send e-mail to named mutiple receipents

$
0
0
Warm greetings:)

I am an HR, and I would like to create a Marco that can help me to send e-mail to named mutiple receipents based on my report. As I am entry-level learner of VBA, it would be highly appreciated if you could explain the details. Thank you in advance!

For example:
1. Select 'No.' as 1
2. You can see there are 4 LM's e-mail addresses
3. Send e-mail to those 4 receipents with the content '1 will be left the company soon.'
4. Keep going on doing the same steps as 1-3 for 2, 3... till the end number

No. LM's e-mail
1 a@hotmail.com
1 b@hotmail.com
1 c@hotmail.com
1 d@hotmail.com

2 e@outlook.com
2 f@outlook.com
3 a@hotmail.com
3 b@hotmail.com
3 f@outlook.com
3 d@hotmail.com
3 g@outlook.com
3 e@outlook.com
...

replacing name with a variable

$
0
0
Hello.
Still very new to VBA so if this lot appears to be the ramblings of an idiot please humour me:)

Below is my spreadsheet(on sheet 1 of my workbook) with the following fields.ID, author,book title,publisher,year published,genre and copies sold.I turned the sheet into a table.Then on sheet 2 of my workbook,in Column A I placed 3 names of the authors from the spreadsheet.
Then I created a macro to go to sheet 2 and choose the name of an author.I did this by clicking on the authors field in the table,then selecting text filters option and pasting the name of the author in the Equals box in the custom autofilter.Then the macro would copy the name,filter the data and paste it onto sheet 3.
The problem arose when I changed the names of the authors that I wanted to select in sheet 2.Instead of getting the data of the new aithor it would go back to the original author.This is logical because that is what the original macro did.
So I have been looking for a way to replace the authors name in the macro code with a variable.Here is the code as it stands:
Code:

Sub Authors()

    Range("A2").Select
    Selection.Copy
    Sheets("Sheet1").Select
    ActiveSheet.Range("$A$1:$G$101").AutoFilter Field:=2, Criteria1:= _
        "=carol reed", Operator:=xlAnd
    Range("A21:G27").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet3").Select
    ActiveSheet.Paste
    Range("A1").Select
End Sub

and next is the code I replaced it with.I created a variable called sun,and then allocated this to the address of the author in column A in sheet 2.I then replaced the name of the author with the variable sun in the actual VBA code.However it's not working and I think I may be doing something wrong.Then it occurred to me that this might not be at all possible within the realms of VBA I thought I would put it up here and see if any one has any suggestions.Thankyou
Code:

Sub Authors()
Dim sun As String
 Range("A1") = sun
    Range("A2").Select
    Selection.Copy
    Sheets("Sheet1").Select
    ActiveSheet.Range("$A$1:$G$101").AutoFilter Field:=2, Criteria1:= _
        "=sun", Operator:=xlAnd
    Range("A21:G27").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet3").Select
    ActiveSheet.Paste
    Range("A1").Select
End Sub

below is a copy of the sheet:

ID author book title publisher yearpublished genre copiessold
75 arnold laing laughter blue parrott 2014 adventure 789000
74 arnold laing smile blue parrot 2014 adventure 657000
76 arnold laing mr softy zoot 2015 thriller 89000
77 arnold laing mrs softy zoot 2015 thriller 671000
78 arnold laing gadabout yonkers 2016 thriller 345000
79 arnold laing superfly yonkers 2017 thriller 780000
80 arnold laing daft yonkers 2013 romance 890000
81 arnold laing silly yonkers 2013 romance 967000
73 arnold laing beaty zoot 2014 romance 450000
12 arthur smith which one blue parrot 2016 crime 180000
20 arthur smith the life of eddy bluesocks blue parrot 2015 biography 98000
19 arthur smith heart of the matter zoot 2013 biography 178000
18 arthur smith goldmine blue parrot 2014 crime 225000
17 arthur smith the beach blue parrot 2016 adventure 187000
16 arthur smith out of time zoot 2017 adventure 236000
15 arthur smith watershed zoot 2013 adventur 134000
13 arthur smith believe blue parrot 2015 crime 230000
11 arthur smith angel blue parrot 2016 crime 249000
14 arthur smith taxi to nowhere blue parrot 2017 crime 380000
100 carol reed light on the horizon yonkers 2013 thriller 986000
94 carol reed shifty yonkers 2014 thriller 67000
95 carol reed the big job yonkers 2014 thriller 24000
96 carol reed tell no lies yonkers 2015 thriller 479000
97 carol reed once blue parrot 2016 romance 456000
98 carol reed spice blue parrot 2017 adventure 789000
99 carol reed if only yonkers 2013 biography 231000
88 cathy ellis the years yonkers 2016 thriller 349000
91 cathy ellis jingles blue parrot 2013 adventure 670000
89 cathy ellis sad eyes blue parrot 2017 romance 987000
82 cathy ellis history yonkers 2014 romance 890000
87 cathy ellis in the wind yonkers 2016 romance 789000
86 cathy ellis autumn blue parrot 2015 romance 999000
84 cathy ellis winter blue parrot 2015 romance 780000
92 cathy ellis the grand zoot 2013 biography 123000
83 cathy ellis summer blue parrot 2014 romance 987000
93 cathy ellis romance and mr norman blue parrot 2013 romance 987000
90 cathy ellis talk to the wind blue parrot 2017 romance 967000
85 cathy ellis spring blue aprrot 2015 romance 997000
59 colin wilson head for heights zoot 2017 adventure 992000
56 colin wilson dapper blue parrot 2014 adventure 67000
58 colin wilson pirate blue parrot 2015 adventure 890000
60 colin wilson the calling zoot 2017 thriller 567000
61 colin wilson gadget man yonkers 2013 thriller 654000
62 colin wilson in from the cold yonkers 2013 thriller 780000
57 colin wilson shark blue parrot 2014 adventure 457000
51 gilbert riley sound bite blue parrot 2013 thriller 976000
43 gilbert riley mr jones investigates yonkers 2014 crime 178000
44 gilbert riley mr jones and the ghost yonkers 2014 crime 278000
45 gilbert riley mr jones in the dock yonkers 2017 crime 679000
46 gilbert riley mr jones and the bank job yonkers 2016 crime 456000
48 gilbert riley the return of mr jones yonkers 2013 crime 679000
47 gilbert riley goodbye mr jones yonkers 2013 crime 811000
49 gilbert riley the life of rome yonkers 2017 biography 211000
50 gilbert riley one amongst many blue parrot 2014 thriller 234000
52 gilbert riley you and me blue parrot 2013 romance 154000
53 gilbert riley fancy that zoot 2017 thriller 167000
54 gilbert riley give and take zoot 2015 romance 987000
55 gilbert riley showtime zoot 2016 adventure 45000
30 gill rafferty sign of the times zoot 2013 romance 980000
29 gill rafferty goblin blue parrot 2014 romance 456000
28 gill rafferty ghost blue parrot 2016 crime 450000
27 gill rafferty the sea yonkers 2013 romance 890000
26 gill rafferty rhodes yonkers 2015 crime 789000
31 gill rafferty mindfull yonkers 2014 crime 378000
22 gill rafferty sign of the times yonkers 2017 thriller 679000
25 gill rafferty evening yonkers 2015 romance 890000
21 gill rafferty old town yonkers 2016 thriller 178000
24 gill rafferty clouds blue parrot 2013 romance 189000
23 gill rafferty the rockstar yonkers 2016 thriller 670000
32 gill rafferty minds eye yonkers 2017 crime 890000
66 james green mask blue parrot 2016 romance 789000
72 james green the net zoot 2013 adventure 976000
71 james green the abbot blue parrot 2013 biography 123000
70 james green fishy zoot 2013 thriller 890000
69 james green tides zoot 2017 crime 378000
67 james green blue skies blue aprrot 2016 romance 907000
65 james green solitiude yonkers 2015 crime 780000
64 james green paradise yonkers 2014 crime 989000
63 james green flame yonkers 2014 crime 560000
68 james green lonely blue parrot 2017 romance 983000
10 ken davies switch zoot 2015 adventure 180000
2 ken davies dawn watch zoot 2013 adventure 260000
3 ken davies zero hour zoot 2015 adventure 279000
4 ken davies mr evans zoot 2013 crime 155000
1 ken davies xpatrol zoot 2017 adventure 175000
5 ken davies revenge blue parrot 2015 crime 225000
6 ken davies backdrop zoot 2003 crime 175000
7 ken davies firefly zoot 2014 crime 640000
8 ken davies newstime zoot 2014 adventure 450000
9 ken davies the department zoot 2014 crime 275000
34 molly brown escape blue parrot 2016 romance 234000
42 molly brown the ship blue parrot 2013 thriller 69000
35 molly brown forever yonkers 2015 romance 980000
36 molly brown serach for mr wrong zoot 2014 biography 478000
37 molly brown wonderful zoot 2013 thriller 878000
38 molly brown gilbert zoot 2013 biography 455000
39 molly brown shoulder to cry on yonkers 2015 romance 671000
40 molly brown jonah yonkers 2017 biography 689000
41 molly brown candid yonkers 2017 romance 790000
33 molly brown loves lost blue parrot 2017 romance 345000

convert formula to vba

$
0
0
please help me too with my formula into VBA code
my formula for 31 cells:
c50->ag50 with text format (csd, csn)
drow 52 and row 326 number format (135, 127...)
first cell in AQ50:
=IF(AND(OR(C50="CSD";C50="CSN");C$9=1);IF(C52<>"";C52&",";C$326);"")
next cell
=IF(AND(OR(D50="CSD";D50="CSN");C$9=1);IF(D52<>"";D52&",";C$326);"")
...
last cell
=IF(AND(OR(AG50="CSD";AG50="CSN");C$9=1);IF(AG2<>"";AG52&",";C$326);"")

I need function for all cell and next sum (AQ50+AR50...+BU50) with delimiter "," .
thank you

VBA Excel - Null The Value of a cell when the value of another cell changes

$
0
0
Hello,

I have never used VBA. I saved my excel file in xlsm and put this code:

Code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Range("d1").Address Then
Range("d5").Value = ""
End If
End Sub

But its not working. The idea is when i change my first dropdown menu the second one to be null.
Attached Files

ImportHTML to auto fresh in Sheets

$
0
0
Hi all,
Not sure if I'm in the right place - as this is about google sheets, please correct me if I'm wrong

I'm currently using a few IMPORTHTML to import NFL scores directly into google sheets. I was wondering if I could get that information to Auto refresh. I've been reading other people who have had similar questions and have used scripts to accomplish this.
I'm very unsure of scripts, so I'm looking to see if someone could help me or let me know if what I'm looking for is possible. I thank everyone for their help!

A1=importxml("http://www.nfl.com/liveupdate/scorestrip/ss.xml","//g/@q" )
B1=importxml("http://www.nfl.com/liveupdate/scorestrip/ss.xml","//g/@h" )
C1=importxml("http://www.nfl.com/liveupdate/scorestrip/ss.xml","//g/@hs" )
D1=importxml("http://www.nfl.com/liveupdate/scorestrip/ss.xml","//g/@v" )
E1=importxml("http://www.nfl.com/liveupdate/scorestrip/ss.xml","//g/@vs" )

Using multiple Advanced Filters/different ranges?

$
0
0
Hello all
I would think it's possible to have more than one advanced filter in a workbook, but I keep getting errors. I'm using a multi-page form to manage two separate lists of data, each page would have the ability to search for existing data in its relevant list.

So am I trying something not possible? Or just missing an obvious error?

Using Macro to add google's first image link to Excel

$
0
0
Hello Everyone


i'm trying to use Macro to add the first image link from google to b1 for every a1 value.


i have more than 1000 value that need images.

can you please help on that?

i use windows 10 and MS 365

please support

thanks

[SOLVED] Comparing figures in 2 variables results confusion.

$
0
0
In a userform I have 4 textboxes with figures in each, txt1 = 1981.44, txt2 = 1110.00 txt3 = 145.28 & txt4 = 3236.72

I have 3 variables set as Double, Total, Comparison & Difference.

Total = txt1 + txt2 +txt3 (3236.72)

Comparison = txt4 (3236.72)

Difference =Comparison – Total

I expected the variable Difference to = 0, but it returns -4.54747350886464E-13:confused:

I have this problem, so far, on only 6 records (with different figures) across 4 sheets, about 1000 records, but with different results, e.g. 1.136886837721616E13 and 5.6843418860808E-14.

I can’t find any pattern or reason why 6 out of about 1000 records show a problem, although the figures do equal each other.

I can’t attach the actual workbook that I am working with as it is full of sensitive data and reliant on other workbooks being in the same folder.

I have mocked-up and attached an example that acts the same.

Any help would be appreciated,
Tina
Attached Files

Master file to split into various existing templates

$
0
0
Dears,

I would like to copy from Master file and paste into multiple excel file.

1. Copy from sheet 'Raw'
2. Filter based on column 'H',
3. This should be copy pasted into the filtered existing file name template with the sheet name 'Data' (Almost 50 Templates.

Any help would be highly appreciated.

Thanks in advance.

[SOLVED] Font Color change based on Cell Interior.ColorIndex changes

$
0
0
Hi Folks
I have this code that I am working on and I want to change the Font color in the cell to white if the Interior.ColorIndex has changed from white

Code:

Private Sub Worksheet_Calculate()
' Simulates conditional formatting (for pre-2007 users).  Changes agent's name background depending on cell value.

Select Case Application.WorksheetFunction.CountIf(Sheet1.Range("F" & Selection.Row & ":K" & Selection.Row), ">" & 0)
    Case 0
        Range("C" & Selection.Row).Interior.ColorIndex = 0
    Case 1
        Range("C" & Selection.Row).Interior.ColorIndex = 12
    Case 2
        Range("C" & Selection.Row).Interior.ColorIndex = 20
    Case 3
        Range("C" & Selection.Row).Interior.ColorIndex = 45
    Case 4
        Range("C" & Selection.Row).Interior.ColorIndex = 47
    Case 5
        Range("C" & Selection.Row).Interior.ColorIndex = 37
    Case 6
        Range("C" & Selection.Row).Interior.ColorIndex = 41
End Select

End Sub

Best Regards,

John

[SOLVED] Edit VBA code without automatically executing code

$
0
0
Got myself into a foolish situation.

I have a procedure that runs automatically when the workbook opens. When the application finishes I recently put in a application.quit.
Now I can’t get in to edit the code - it runs and quits when I open the workbook. I’m using a Surface and I can’t even find the break key!

Is there any way to edit the code without triggering the automated start of the code?

How to limit FIND searches to a specified range ?

$
0
0
I need to check if there are occurrences of a word in column A. I use this simple code:
Code:

Columns("A:A").Select
1  On Error GoTo 2
    Cells.Find("sun", ActiveCell, xlValues, xlPart, xlByColumns, xlNext).Activate
    ActiveCell = ""
    GoTo 1
2  MsgBox "Not found"

It works all right bcs FIND returns ‘Error’ when there are no occurrences or no more.
The trouble is that it will go on beyond the specified range of column A and find occurrences anywhere in the worksheet, which I don't want. How can I restrict the search to the specified range only?
(I know there are other functions like For… Next… with Set…, etc. But FIND is more economical in terms of code lines and I want to keep it short bcs my macro is already very long).

VB code to check if file exit before opening excel file.

$
0
0
Hello:

I need a VB Code to check the following when i open any excel file.

Need to check if C:\User\test.xlb exist.

If this file exist then open the excel file otherwise give message and close the excel file.

Please let me know if you have any questions.
Thanks.

Riz

Creating macro to search, copy and paste to another worksheet help

$
0
0
Hello All,

Need help with the following:

Have 2 worksheets called Bulk and Micro want to copy the results from the Micro sheet and pasted in the Bulk sheet using the PO Number

Untitled.jpgUntitled2.jpg

Thanks

[SOLVED] Custom Search Button (Cancel help)

$
0
0
I created (with help) a custom search button awhile back. It works flawless, however if you click CANCEL it seems to search for empty spaces. I need it to just close the box when you hit cancel.

Code:

Sub SearchAndFindRibbon(control As IRibbonControl)
    Dim str As String, sh1 As Worksheet, c, x As Long, y As Long
    Set sh1 = Sheets("Current")
        'With sh1.Range("e1:J5000") 'note: you can specify a last used range here for efficiency
        With sh1.Cells
        str = "*" & InputBox("Search for?") & "*"
        Set c = .Find(str, LookIn:=xlValues)
        x = Application.CountIf(sh1.Cells, str)
        y = x - 1
        If Not c Is Nothing Then
            firstaddress = c.Address
            Do
                Application.Goto c
                Msgtext = MsgBox("Found: " & x & " Matches" & vbNewLine & vbNewLine & _
                                "Remaining: " & y & vbNewLine & vbNewLine & "Goto Next?", vbYesNo, "Itterate Through Found Values")
                If Msgtext = vbNo Then
                    Exit Sub
                Else
                    GoTo 1
                End If
1
                Set c = .FindNext(c)
                y = y - 1
                If y = 0 Then Application.Goto c: Exit Sub
            Loop While Not c Is Nothing And c.Address <> firstaddress
        End If
    End With
End Sub

Viewing all 50243 articles
Browse latest View live