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

xml fixed field length

$
0
0
Hi,
I need to export an Excel field to XML with a fixed field length.
So

<Debtor code="1007">
</Debtor>

Needs to be fixed on 20 characters.
<Debtor code=" 1007">
</Debtor>


I am using this code (part of it)

Code:

        Print #FileNum, "          <Debtor code="; Chr(34); Range("Debtor").Text; Chr(34); ">"
        Print #FileNum, "          </Debtor>"


So I need to format the "Range("Debtor").Text" field fixed on 20 Characters.
How would I do that ?

Select matching item in userform combo box

$
0
0
I'm trying to select the correct name in a userform combo box. Below i've captured the engineers name in a variable from a separate worksheet, now i want to force the combo box to select the matching name, i can't seem to get this to work any suggestions:eek:

Also any suggestions to eliminate all the repeatative if statements:)

Thanks

Code:

If myVar5 = "Bob" Then
    frmPlanning.cboEngineer.List = (.ListIndex = 0)
End If
If myVar5 = "Fred" Then
    frmPlanning.cboEngineer.List = (.ListIndex = 1)
End If
If myVar5 = "Larry" Then
    frmPlanning.cboEngineer.List = (.ListIndex = 2)
End If
If myVar5 = "Steve" Then
    frmPlanning.cboEngineer.List = (.ListIndex = 3)
End If

Show a label to identify a row

$
0
0
I have n rows of data with many columns, I need to scroll the row to see all of the columns.

Is there a way, VBA code I assume, to hover or click on a any row cell and get a label that shows the row date, which is in column C, so I know that I am on the correct row while looking at the data, without going back to the beginning of the row to check? I would prefer not to use the split screen mode.

Macro to pull an excel attachment from an email

$
0
0
Hi there,

I am looking to create a macro to pull an excel attachment from an Outlook email and put the data from that sheet into another excel sheet.
The email attachment will have names in col A and a corresponding number in col B.
What I would ideally like to happen is that a graph will be created from the data that I pull from the email attachment to the other excel page

Any help would be great :)
Thanks in advance,

Johnny

Error msg. Subscript out of range

$
0
0
I am trying to get my head around some VBA and ran across a video series on you tube that seems to be easy enough for an old novice to grasp, however in a very early lesson I am trying to complete this example but I am running into a wall.

When I try to run the following code I get an Error message "Subscript out of range" and I have been unable to get any further. I have tried renaming the target sheet but to no avail. I am at an impass. Any ideas?

The series is done by Excel VBA is Fun. This is the link to the lesson.

HTML Code:

https://www.youtube.com/watch?v=ZkblABsFHWc
Code:

Sub StartTimer1()
    nr = ThisWorkbook.Sheets("Timer").Cells(Rows.Count, 1).End(x1up).Row + 1
    Cells(nr, 1) = Time
End Sub

Thanks
Jim O

Loop to write sheets name in column

$
0
0
Hello. I have a workbook with 180 Sheest. I need to copy sheet name and paste to column Name.
In the Column Year write 2013.Finally I need to all sheets as show below in in Sheet Farms.
Doing this one by one is time consuming and with error risk. I think a loop can do this,
nevertheless, I don´t Know how to do it. Your help is really appreciated.
Column size can be different in each Sheet

Sheet name Famr1
Cod Name Year Desc Total1 Total2 Prov Cnt
1234 Apples 200 xxx yyy zzz
3412 Bananas 400 xxx yyy zzz
2358 Oranges 500 xxx yyy zzz
8956 Pines 800 xxx yyy zzz
...
...

Sheet name Famr2
Cod Name Year Desc Total1 Total2 Prov Cnt
2345 Apples 200 xxx yyy zzz
4126 Bananas 400 xxx yyy zzz
...
...

Sheet name Famr3
Cod Name Year Desc Total1 Total2 Prov Cnt
2345 Apples 200 xxx yyy zz
4126 Bananas 400 xxx yyy zz
5698 Peanuts 650 xxx yyy zz
8756 Grapes 350 xxx ppp zz
5698 Olives 280 xxx ppp
5879 Pear 150 xxx rrr
....
....

Sheet Farms
Cod Name Year Desc Total1 Total2 Prov Cnt
1234 Farm1 2013 Apples 200 xxx yyy zzz
3412 Farm1 2013 Bananas 400 xxx yyy zzz
2358 Farm1 2013 Oranges 500 xxx yyy zzz
8956 Farm1 2013 Pines 800 xxx yyy zzz
2345 Farm2 2013 Apples 200 xxx yyy zzz
4126 Farm2 2013 Bananas 400 xxx yyy zzz
2345 Farm3 2013 Apples 200 xxx yyy zz
4126 Farm3 2013 Bananas 400 xxx yyy zz
5698 Farm3 2013 Peanuts 650 xxx yyy zz
8756 Farm3 2013 Grapes 350 xxx ppp zz
5698 Farm3 2013 Olives 280 xxx ppp
5879 Farm3 2013 Pear 150 xxx rrr
....

Populate Web Page Entryfields with Excel Data

$
0
0
I have a web page that has 10 to 20 entryfields that I have to individually type in. I would like to run an excel macro that would allow each field to automatically populate the web page. Then all I would click is the submit button.

In other words, I open excel and open the web page. I then go back into excel and select a row. Then all of the data in that row would populate the web page entryfields. Now I hit the submit button and go back to the next row in excel and repeat.

Is this possible? Any help in setting this up would really be appreciated.

Getting Live MT4 forex data

$
0
0
I create this WB to get live data from MT4, but i need help to fix the code as the vba cannot stop, and end everytime with error, how to stop the vba?

the code will round the data of MT4 into every 5 sec data, and list them in S column, now i need also the code to calculate and fill the Open High Low Close columns for the specific time frame, like for example 2 min interval's ohlc, thank you
Attached Files

Insert # of Rows based on User Input

$
0
0
I have an excel sheet that I've automated for my shop ... Basically it copies a set of rows from one sheet, asks for which cell you want to start the paste at, then pastes it... Here's what I have so far:

Code:

Sub CP()
' CP Macro

Dim strReturn As String
 
strReturn = Application.InputBox(prompt:="ENTER a Single Cell Address or " & _
                        "Range(A1, F6, B12:M32, etc.)", Type:=2)
 
If strReturn = "" Then Exit Sub

    Sheets("Data").Select
    Rows("1:15").Select
    Selection.Copy
   
    Sheets("Tracker").Select
    Range(strReturn).Select
    ActiveSheet.Paste
End Sub

So I tried to use a variation of strReturn to indicate number of rows wanted but that didn't work ... Basically I'm going to create the "data" to include 50 rows, but have it selectable for the user to say they only want 5, 7 or 29 rows ... Any ideas ?

Thanks!

Code to TRANSPOSE Rows to Columns

$
0
0
Hi Excel Forum,

I recently joined the group and new to this job. Please help me keep it!

I have a huge file with names, addresses and account types & numbers. However, there's a separate row for each account type instead of listing the person's name once and indicating all of their account types on that row as well in separate columns. I've seen several post regarding different Macro codes to use; however, none work for my project since I have several columns that need to be compared beginning on A2:K2 to A24628:K24628. I have attached a small example for your review. Please Help! Thanks!
Transpose Needed.xlsx

Need you help! $20 offered for Macro // centralize and rearrange data for pivot table.

$
0
0
Hi everybody!

I am confronting a little issue at my work, namely I need to centralize data from several input files into a master file, which requires a lot of manual work and is very time consuming.
What I trying to do and I am not really able to, due to my rather poor VBA knowledge, is to develop a macro that would allow me to get the data together into a master file from several files that lye in the same folder as the master file. Therefore, the link between the master file and input files could be done via pfads or by setting the macro to import into the master file all the data from the input files available in that specific folder. It would be really great, if someone could provide me with both solutions, as things might change in the future.

However, my biggest problem is that I can't really find a macro to get the data imported so that I could straight away use it for a pivot table. Here, one would need to rearrange a little bit the data, as it follows:
1. Column headlines should be taken over from A3:H3 (see attachment)
2. Data starting from F4 till column DW4 should be listen one after another on the vertical axis on a monthly basis. Each month comes with 3 columns and approximately 10 rows.
3. It would be great if the date for each month would be taken over in a column in the very front, say column B
4. Column A should represent the date when the report is being established.
Macro Data.JPG

Basically it should look like this:

A |B |C |D |E |F |G |H |I |J
mm.jjjj |Date | Department | Team | Function | Profile | Level | Heads | FTE | Effect FTE
| 01.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 1 | 1 | Replacement
| 01.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 1 | 1 | Employment
| 01.01.2015 |HR/SC |Rainer | HR Admin Nord | Support| Student | 0,5 | 0,5 | Employment
| 15.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 15.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 15.01.2015 |HR/SC |Rainer | HR Admin Nord | Support| Student | 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Support| Student | 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Proj. M.| Junior | 1 | 1 | Employment
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | -1 | -1 | Layout
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Support| Student | 0 | 0 |
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Proj. M.| Junior | 0 | 0 |

Big thanks!
As soon as we get it working I’ll be transferring the $20 per PAYPAL:)

Find Text and Insert Formula

$
0
0
Hi Everyone,

I am on the verge of perfecting this macro just need help pushing over the top

Want to Find text in Column A and insert a formula into Column H that will sum Cell Adjacent In G and the One Below It.

This goes through an entire work sheet and is not even

Ex: Find text in A5 and want a formula in H5 that will sum G5 & G6

My Macro Formula is off but everything else works fine. The $ keeps going into 6 Locking that cell which is what I DONT want

This is what I have thus far THANKS!!

Code:

Sub MyMacro()


    Dim myLastRow As Long
    Dim myRow As Long
   
    Application.ScreenUpdating = False
   
'  Find last row with data in column B
    myLastRow = Cells(Rows.Count, "B").End(xlUp).Row
   
'  Loop through all rows in column B looking for the word "total"
    For myRow = 5 To myLastRow
        If Cells(myRow, "A") = "8p-12a Premieres" Then
            Cells(myRow, "H").FormulaR1C1 = "=(RC[-1])+(R6C[-1])"
        End If
    Next myRow
   
    Application.ScreenUpdating = True
   
End Sub

Macro to rearrange data for pivot table

$
0
0
Hi everybody!

I am confronting a little issue at my work, namely I need to centralize data from several input files into a master file, which requires a lot of manual work and is very time consuming.
What I trying to do and I am not really able to, due to my rather poor VBA knowledge, is to develop a macro that would allow me to get the data together into a master file from several files that lye in the same folder as the master file. Therefore, the link between the master file and input files could be done via pfads or by setting the macro to import into the master file all the data from the input files available in that specific folder. It would be really great, if someone could provide me with both solutions, as things might change in the future.

However, my biggest problem is that I can't really find a macro to get the data imported so that I could straight away use it for a pivot table. Here, one would need to rearrange a little bit the data, as it follows:
1. Column headlines should be taken over from A3:H3 (see attachment)
2. Data starting from F4 till column DW4 should be listen one after another on the vertical axis on a monthly basis. Each month comes with 3 columns and approximately 10 rows.
3. It would be great if the date for each month would be taken over in a column in the very front, say column B
4. Column A should represent the date when the report is being established.

Macro Data.JPG

Basically it should look like this:

A |B |C |D |E |F |G |H |I |J
mm.jjjj |Date | Department | Team |Function | Profile | Level | Heads | FTE | Effect FTE
| 01.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 1 | 1 | Replacement
| 01.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 1 | 1 | Employment
| 01.01.2015 |HR/SC |Rainer | HR Admin Nord | Support|Student| 0,5 | 0,5 | Employment
| 15.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 15.01.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 15.01.2015 |HR/SC |Rainer | HR Admin Nord | Support|Student| 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Support| Student| 0 | 0 |
| 01.02.2015 |HR/SC |Rainer | HR Admin Nord | Proj. M.| Junior | 1 | 1 | Employment
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | -1 | -1 | Layout
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Leader | Senior | 0 | 0 |
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Support| Student| 0 | 0 |
| 15.02.2015 |HR/SC |Rainer | HR Admin Nord | Proj. M.| Junior | 0 | 0 |

Big thanks! :)

Quotes, Picklists, Parts Database

$
0
0
Hi,

Im very new to VBA and come to a dead end with my program so need a helping hand. What I am trying to do is:

1. Create a list of parts divided into sections to suit each part.
2. Select each part number using a Checkbox which enables a text box (for quantity)
3. When I type in my quantity I want to press enter key and the data to be copied to another worksheet in the same book.
4. I also have prices and other information on another sheet which I would like to copy along with the above, but can we get the above sorted and move on from that?

Many Thanks
Scott McQ

Macro Insert Row

$
0
0
I am trying to get a macro to insert a new row when it hits the selection.Insert instead of holding the row number it selects the entire document and inserts thousands of rows... can someone give me the simple fix for this issue...

Code:

Rows("9:9").Select
    Selection.Insert Shift:=xlDown


Simply Copy and pasting data from one sheet to another sheet but certain cells....

$
0
0
How do you copy and paste certain cells to another sheet behind the scenes, when recording a macro it obviously runs and you can see the mess and its annoying how do I get away fro this...

Here is what I have, basically a data sheet that has inventories on one page, they are in the same cells everytime so I need to select say cell B1, B15, B30, C12 and so on and paste them into a row that is simply the inventories so B2, B3, B4, B5, B6 straight across matching them with their header... they will always be copied from the same cells and always be pasted into the same cell location....


T

Select the top cell (row 1) in active column

$
0
0
This seems so simple, but for some reason I just don't get it. I want a simple macro which will go to the cell in row one in the active cell's column

COUNTIFS function with possible MACRO solution

$
0
0
This is crosspost from the functions/formulas board, but maybe someone with Macro knowledge can help with this problem:

I have 4 Columns: D (Containing a time), E (Containing the hours 0-23), H (Containing names), and I (Containing the list of names in H). For the first step, I am trying to discern the number of times a specific name appears per hour of the day. To do this, I wrote the function =COUNTIFS($H$H, $I$2, $D$D, $E$2:$E$25) to resolve in new column L (Count of times a name appeared per hour in a 24 hour period). This gives me the solution no problem, and I can expand the solution over the 24 hours per name. My problem occurs when I try to expand the solution across other names (when I create new columns, M, N, O, etc). My whole issues revolves around the "I" column. I can lock down the column as "I", but I want the function to follow from I2 to I3 to I4 and so forth. If I do not lock down the column "I" and expand the function to these columns, that criteria then resolves to J2, K2, J3, K3, and so forth.

A sample file can be found at the bottom of the previous thread: http://www.excelforum.com/excel-form...-new-post.html

Adding Multiple Rows Depending on Column Content

$
0
0
Hello All. I am coming back once again to this forum that has helped me tremendously with other projects. I am hoping someone can help me out here I am totally stumped and not sure if excel has this capability to do what I need. Basically my distributor of automotive parts provides me with a spreadsheet of auto parts and their compatibility. I am trying to list some of these items in bulk.


A sample of the list my distributor gives me can be found here: SampleOfProductData.xlsx


I am trying to list in bulk to eBay. Ebays requirements for bulk upload for automotive compatibility is a pain in the rear. A sample of what they require can be found here LayoutNeeded.xlsx

Is there any code that can be made to take the distributor’s spreadsheet and run a code that will put the in the requirement layout under the columns “relationships” and “relations_details” as ebay requires adding multiple rows per year make and model groups?

User Login Form using VBA

$
0
0
Hi All,

Iam a new user of VBA. And Iam creating a user login form. I have a work book with 2 userforms in it (Login and Activities). I have another workbook which has the list of usernames and passwords. Now I have to give access to these users so that they should be able to login with their user id, password and their role and once they log in they should be able to view the Activities userform.

Please help me in this.
Thanks in advance...
Attached Files
Viewing all 49956 articles
Browse latest View live