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

Autopopulate (horizontally) cells in calendar via UserForm

$
0
0
Hi,

I have a file with some sheets, one sheet for every month-the days from 1-31 are populate via UserForm, one sheet a sort of control/summary, a sheet for public holidays.
When a guy wants a vacation I wanna type the date in a textbox and the required days in another one.
I want to populate horizontally the cells when the values are entered in textbox (the date) and the rq days excluding the weekends and the public hol.
I tried different methods but unsuccessful.
also posted here
http://www.thecodecage.com/forumz/forumdisplay.php?f=64

I really appreciate your help!
Attached Files

clear contents vs delete

$
0
0
Greetings all,
I have a spreadsheet and on the spreadsheet I have many named ranges. I have quite a few sub routines on the worksheet change event

for example

cell b22 is named range vdom1
cell b23 is named range vdom2
cell b23 is named range vdom3
cell b24 is named range vdom4

I have a worksheet change event sub for each of the above that will hide or make visible other rows on other sheets. if I for example delete the contents of b22 then the worksheet change happens properly, same if I delete the contents of cell b23. If I select all of the cells and then clear contents it does not trigger the worksheet change events. I am going to asssume that the users will select all cells like above and say clear contents to start over. Is there some way to say that if a user selects multiple named range cells and then says clear contents that it will run the sub routines for those cells?

# multiple data with one code #

$
0
0
I want copi continius by criteria in col FGH
then i use loop col on by one after F then G and H
Screenshot_74.png
if col "FGH" = 1 then run copi to J3 then after criteria F then to G copi J13 then
with one code bellow what must i do
Code:

Sub Copikan()
Dim CR, Col As String: CR = "FGH"
Dim R, RngSimpan As Range
For Each R In Range("A3:E9")
  For i = 1 To 3
    Col = Mid(CR, 1, i)

    If Range(Col & R.Row) > 0 Then
      If RngSimpan Is Nothing Then
        Set RngSimpan = Range(Cells(R.Row, 1), Cells(R.Row, 5))
      Else
          Set RngSimpan = Union(RngSimpan, Range(Cells(R.Row, 1), Cells(R.Row, 5)))
      End If
    If Not RngSimpan Is Nothing Then
    RngSimpan.Copy Range("J3")
  End If
     
        End If
    Next

 Next
End Sub

Ping tester

$
0
0
How can i write a batch script for ping tester .which run at background without disturbing .

Unable to set the FormulaArray property of the Range Class

$
0
0
I am having some trouble with the following,
-I have noticed this error seems to come up when the formula is > 255 characters; people have then split the formula in two. The formula I have posted is 223 character and I currently have this formula in the cells and it is working.

-I have only pasted the first part of the code i.e. the range going from H5:H29, I basically have the same formula except the LARGE part changes by 1.

Sheet17.Select
Dim c As Range

For Each c In Range("H5:H29")
Range("H5").FormulaArray = "=INDEX(INDIRECT($G$1),MATCH(LARGE(IF(COUNTIF($H$4:H4,INDIRECT($G$1))=0,SUMIF(INDIRECT($G$1),INDIRECT($G$1),INDIRECT($G$2)),""),1),SUMIF(INDIRECT($G$1),INDIRECT($G$1),INDIRECT($G$2))*(COUNTIF($H$4:H4,INDIRECT($G$1))=0),0))"

Next c

End Sub

Copy specific files from subfolders to new folder

$
0
0
Hi all, wish you an early Happy New Year!

I am new to using VBA, looking for help to create a macro that can copy some specific .csv files from subfolders (there are subfolders within subfolders, below is the path I need to copy the files from) to a new folder.

Path: ..../A/B/C/D

A: multiple folders in this level, I need to loop through all
B: multiple folders in this level, I need to loop through all
C: multiple folder in this level but I only need to go into 1, so C is fixed
D: all the .csv files within C that I want to copy to a new folder on desktop

***Also, before I copy any .csv files to the new folder, I want to change its name from "D" to "A - B - D"***

Your help would be greatly appreciated! Thanks!

Macro to loop through fixed number of worksheets?

$
0
0
I have created a macro to correct some formatting on a worksheet. There are 120 identical worksheets in the workbook.

I'm trying to expand the macro to have it step through the 120 sheets. I can write the loop, but how do I get the macro to step to the next worksheet as it loops?

Thanks!

Copy cells between worksheets, leaving unchanged in target worksheet if condition not met?

$
0
0
I need to automatically copy certain cells from the columns in "Grid" to the corresponding cols in "Sched" - just the cells that have "OFF" in them, leaving the other cells in "Sched" unchanged (including colors). Is this possible with any formulas, or better to use VBA? Thanks for any advice on this...
Attached Files

How to select dynamic array

$
0
0
I want to select sheet 6 through last sheet, how do I do so using vba? I'm not sure how to make it variable, it will always begin at sheet6 and will end at sheet x.

Code:

Sub Selectsheetstoprint()



        Sheets(Array(6, 7, 8, 9, 10)).Select


End S

Consolidate and add value in next Row

$
0
0
Hi Everyone, Please find attached data and i am trying to create code that will do exactly in example in data attached. All i want in here is if employee pay pension contributions for 100 (Pen EE (Tal)) and employer pay for 200 on behalf of the same employee. Then, the worksheet should look like Colunm A= Pers No, Column B=Employee Name, Colunm C= ID Number, Column D=PenPay, Column E=Pens EE(Tal) and Column F=Pens ER(Tal) and G= Total (Pen EE +Pen ER values)

I hope this makes sense. i have tried several method for the pass 8 hrs but nothing. Thank you all for your help. Please see below attached

Data Download.xlsm

Find Ticker Symbols with name

$
0
0
Hi folks.
I was wondering if anyone had a vba that could essentially take a company name and look it up via yahoo finance to find its ticker symbol.
This would make life so much easier for me since I have to go through about 400 companies on a regular basis this way.
Thank you.

[SOLVED] Range.Find where the value is a formula

$
0
0
I am trying to find a date in a column.
Code:

Set rng = shR.Range("A5:A371").Find(Rpt_Date, LookIn:=xlValues, lookat:=xlWhole)
Cell A5 has the Date 1/1/2016. Cell A6 has the formula =A5+1 ... and so on for the rest of the year.

I think what is happening is find gets to row 366 (which displays 12/28/2016 = Rpt_Date) but sees it as =A365+1.

Any ideas on how to get it to look at the value rather than the formula?

How to Autofill down to last cell

$
0
0
I have a recorded macro that auto fills a formula down R4579 how do I build the macro to always fill down to the last row no matter what the last row is?

Code:

Sub Cybersource_Date()
'
' Cybersource_Date Macro
'

'
    ActiveCell.FormulaR1C1 = "DATE"
    Range("R2").Select
    ActiveCell.FormulaR1C1 = _
        "=DATE(RIGHT(LEFT(RC[-15],11),4),MONTH(1&LEFT(RC[-15],3)),RIGHT(LEFT(RC[-15],6),2))"
    Range("R2").Select
    Selection.AutoFill Destination:=Range("R2:R4579")
    Range("R2:R4579").Select
End Sub

# 2 looping if yes vba run#

Removing Duplicate value from each row

$
0
0
Hi guys ...
Here 's my question that how can I remove duplicate value from each row using VBA ?
( Indeed , I dont wanna use Transpose option to put the rows into columns )

How to select webpage HTML Input element list item

$
0
0
I have been trying to select a specific value of an Input selector on a webpage, without success
Below is the code (part of a much larger automation script) to find the input element which is successful. But have tried various input value selection methods with no success.
A solution would be most welcome

see also image snippets of html and input screenshots

Code:

' find & select Released Prices
        Set htmlColl = objInternetPage.getelementsbytagname("input")
        For Each htmlInput In htmlColl
            Select Case htmlInput.ClassName
                Case "x-form-text x-form-field x-combo-noedit"
                    If htmlInput.Value = "Not released prices" Then
                        Set objInput = htmlInput
                        Exit For
                    End If
            End Select
        Next htmlInput

        If objInput Is Nothing Then Stop
       
        ' Input has 2 values - item 0 = Released prices, and item 1 = Not released prices (default value)
       
        ' but cant select the list item
        ' like this
        objInput.selectedindex = 0
        ' or like this
        objInput.parentelement.Children.Item(1).selectedindex = 0
       
       
        ' this allows activation of the dropdown selector arrow
        objInput.parentelement.Children.Item(1).Click
        ' but cant select the list item like this
        objInput.parentelement.Children.Item(1).selectedindex = 0
       
       
        ' tried this to select Released prices - but no success (populates the input with the value, but does not change the input selection to Released prices item)
        objInput.Value = "Released prices"
        objInput.fireevent ("onchange")

Attached Images

Transport data then create a pivot table

$
0
0
Dear all
I want to transpose the data in range"a15:www20" then create a pivot table from the transposed range.

I want the resulted pivot table like the pivot in report sheet.
I want all these steps to be done using code(but please avoid using copy and paste commands because I donot want to keep transposed table)
Please help me

[SOLVED] Adding a third option to a button

$
0
0
I currently have a button acting as a toggle but now need to offer a third option. How would I alter the code to allow for this please?

Code:

Private Sub CommandButton8_Click()

  If CommandButton8.Caption = "Buyer" Then
    CommandButton8.Caption = "Seller"
    OptionButton1.Value = False
    OptionButton2.Value = True
  Else
    CommandButton8.Caption = "Buyer"
    OptionButton1.Value = True
    OptionButton2.Value = False
  End If

End Sub

Import msg file body text from folder to Excel

$
0
0
Hello everyone!

I have hundreds of saved letters with .msg format from outlook in my computer. I was wondering if there is a way to import body text of all .msg files from folder into the Excel? Each letter into the new row:

Date Msg title Body text

While searching for the answer I did found one code, but unfortunately it is not working for me, the tool appears to be running, but not bringing anything at all:
Code:

Sub importMsg()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.DisplayAlerts = False

    Dim i As Long
    Dim inPath As String
    Dim thisFile As String
    Dim Msg As MailItem
    Dim ws As Worksheet
    Dim myOlApp As Outlook.Application
    Dim MyItem As Outlook.MailItem

    Set myOlApp = CreateObject("Outlook.Application")
    Set ws = ThisWorkbook.Worksheets("Main")

    With Application.FileDialog(msoFileDialogFolderPicker)
      .AllowMultiSelect = False
            If .Show = False Then
                Exit Sub
            End If
        On Error Resume Next
        inPath = .SelectedItems(1) & "\"
    End With
    thisFile = Dir(inPath & "*.msg")
    i = 4
    Do While thisFile <> ""
        Set MyItem = myOlApp.CreateItemFromTemplate(inPath & thisFile)
        ws.Cells(i, 1) = MyItem.Body
        i = i + 1
        thisFile = Dir()
    Loop

    Set MyItem = Nothing
    Set myOlApp = Nothing

    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Application.DisplayAlerts = True
End Sub

Thank you very much in advance!

Sincerely,
VBA noob :confused:

display unique list in dropdown in each subsequent cell

$
0
0
Hi,

I am looking to get a list of unique data without any duplicates to be displayed in dropdown in G column and in gets update with new data in subsequent cells as well in previous cells.But the data so displayed in G column should be unique to F column.For eg.

if I type in F12 = Ram Kapoor,then it will search all the Ram Kapoor corresponding list of data in G column and display in dropdown without any duplicates in G12.
But if in F12,if the data is new type and does not exist then it will allow one to do entry in G column that will be updated in next cells and previous G column cells.

Hope I could be able to make it understand.

Code is included from http://www.excelforum.com/showthread.php?t=1148579

Hope modification in it will ease.
Attached Files
Viewing all 50117 articles
Browse latest View live