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

Sort On Column Descending and Other Column Ascending !

$
0
0
As you may see , I am a beginner !

In Sheet1 , I would like a button to :

- Sort Descending Range D3:D100 from Sheet2
and after that
- Sort Ascending Range C3:C100, also in Sheet2

With "After that" I mean that D3:D100 remain Descending but are resorted by C3:C100 ascending

Thanks

Replace File Name by Cell content

$
0
0
I have this :

Workbooks("Data_Source.xlsx").Worksheets("Sheet1").Range("A2:C101").Copy _Workbooks("Data_Destination.xlsb").Worksheets("Sheet1").Range("C3")

So I want to COPY from Data_Source to Data_Destination

In A1 I have this : xxxxxxx

I want to replace Data_Source.xlsx with A1.xlsx
Must be simple...

And if possible, replace Data_destination.xlsb by File name ! if I save as the file then Data_Destination, change too

Copy the the Interior.Color when a VLOOKUP formula matches using VBA

$
0
0
I use VBA to apply a VLOOKUP formula to a Range in the Active Workbook, but now I need to Copy the Interior.Color (in addition to the value obtained by the VLOOKUP) from the cell when the VLOOKUP finds the matching criteria in the Source Workbook.

Any ideas?

Thanks for any and all help.

JimS

Copy to destination workbook.

$
0
0
Hello,
I have two workbooks. Workbook A is source and B is destination book. I want to make copy A to B. But problem is Book A
range of copy always not same, sometime 10 rows or 15, 29, 34--- rows. On the other hand, destination B book always fixed
rows, say 4 rows. I mean that Workbook B row 1-4 has some text and rows 9-15 has some text. Rows 9-15 text always should be
after copied. I mean, from A 10 when copy to B rows 5-8, then automatically 6 more row insert and row 9-15's text will go down
to row 15-21. Is it possible? If possible, then what is the VBA code? Please, help me.

Data Analysis/Two Way ANOVA of Survey Data with unequal group sizes

$
0
0
Hello, I have a Data Aggregation/Analysis side project that I'm working on. I haven't done anything other than simple data analysis before but volunteered for the project because I like spreadsheets and wanted to learn(and thought I'd be taught what to do). So here is where I am at:

I have a good deal of survey data that I'm looking to analyze. There are 28 numeric-answer questions that I'm looking at. For each participant, I have information(For example colored boxes) that I wanted to use to group people and to determine if there were significant differences between the means of those groups, so I looked up how to do ANOVA. I then learned that I should probably be doing a two way ANOVA with replication. This is where I'm encountering problems, there are several ways I can group the data but of all the different ways no groups will not have equal sample sizes. I already removed the data from participants that didn't answer every question because Excel didn't like the blank spaces. I think I may be doing the wrong statistical test and/or am not doing it right.

I'm looking to determine if there is a significant difference between the Q1 means for each of the box colors, and so one for each question. How would you do it?

The attachment is part of my data without personal information
Attached Files

VB Code to import text file into excel as shown

$
0
0
Hello:

I have text file at C:\Test\Temp.txt .
I need VB code to import this file at cell A1 in excel.

I am attaching both excel and text file to show how it needs to be in excel.

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

R
Attached Files

VBA Solver copy and paste solution for different cells

$
0
0
I have what I think is a simple problem.

In cell B2 I have a number. I allow this number to change to maximize the solution in AC3. I then want to paste this optimized value from B2 into C3.

Then I want to rerun the program. I want B2 to change again, but this time I want to maximize the solution in AC3 and paste the solution into C3. How can I do this for all the way up to AC32 and pasting the solution from each optimization into its correspond cell in column 3?

If I run solver and record the macro, I get this:

Code:

Sub Macro2()
'
' Macro2 Macro
'

'
    SolverOk SetCell:="$AC$3", MaxMinVal:=1, ValueOf:=0, ByChange:="$B$2", Engine:= _
        1, EngineDesc:="GRG Nonlinear"
    SolverOk SetCell:="$AC$3", MaxMinVal:=1, ValueOf:=0, ByChange:="$B$2", Engine:= _
        1, EngineDesc:="GRG Nonlinear"
    SolverSolve

End Sub

So I want this to loop from Ac3 to Ac32

Iterate over excel files & worksheets :confused:

$
0
0
I try to loop over 100 Excel files in a certain directory. For each file - extract a value of the first sheet from cell H10.
For some reason, I am unable to access the first sheet of each file - the marked line returns an error: Subscript out of range.
I'll be glad to receive your help.

Code:


Sub GetDetails()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
Dim directory As String
Dim FileName As String
Dim FilePath As String
Dim SerialNumber As String
Dim MeasuredValue As String
Dim TestDate As String
Dim AcceptedValue As String
Dim sht As Worksheet
Dim LastRow As Long
Dim FileSht As Worksheet

Set sht = ThisWorkbook.Worksheets(1)
'clear range in order to print
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
sht.Range("A2:B" & LastRow).ClearContents

directory = (sht.Range("I1").Value)
If directory = "" Then
    MsgBox "Missing Directory!", vbExclamation, "Missing Directory!"
    Exit Sub
End If

'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder(directory)
i = 1
'loops through each file in the directory and prints their names and path
For Each objFile In objFolder.Files
    'print file name
    FileName = objFile.Name
    'print file path
    FilePath = objFile.Path
    'SerialNumber
    SerialNumber = Workbooks(FilePath).Sheets(1).Range("H10").Value ' ERROR: Subscript out of range
    i = i + 1
Next objFile
MsgBox "Done!", vbExclamation, "Done!"
End Sub


Convert html file to csv

$
0
0
Hello,

I have html file. I need VB code to convert this file at csv format so that I can import it into a database.
The html file contains 5 columns. the first column contains description and code of products. I need to separate them.
some details :
I would like the code that is printed in the second line of the first column (description/code) to be displayed in another column.
And if the description contains two codes, like (texte 2020) it will be duplicated for each.
Also the other thing, if a box is empty, not contain data, it displays it empty.

I am attaching both html file and an example of disred output to show how it needs to be in excel.

Please let me know if you have any questions.

Thanks very much in advance for your help.
Attached Files

VBA Userform Next and Previous Buttons that work on current activesheet/open sheet

$
0
0
I am new to coding in VBA but have been able to figure how to add next and previous buttons. The problem is they always go through the data in "Sheet1" and will not work on the other sheets after I activate them. I have a combobox that will activate a specific sheet but after I active a different sheet the next and previous buttons are still pulling data from the first sheet. What I want them to do is when I hit the next button it will cycle through the data on the activesheet. Any help is appreciated.

The Code for the Next Button:
Code:

Private Sub cmdnext_Click()
If Currentrow < ActiveSheet.Cells(Rows.count, 2).End(xlUp).Row Then
    Currentrow = Currentrow + 1
    cmdnext.Enabled = True
    LoadRow
    If Currentrow = 2 Then
    MsgBox "This is the first entry."
  End If

 End Sub

The code for the previous button is:

Code:

Private Sub cmdprevious_Click()
If Currentrow > 2 Then
    Currentrow = Currentrow - 1
    cmdprevious.Enabled = True
    LoadRow
    If Currentrow = 2 Then
        MsgBox "This is the first entry,"
        End If
  End If
  End Sub

Autosave Invoice In PDF

$
0
0
Hello,

1.I'm using a MAC and the code in my Workbook does not work because it's for Windows.
Any idea how i can save my invoices in PDF in a folder on my MAC Desktop?

Sub SaveInvoiceAsPDFAndClear()
Dim NewFN As Variant
NewFN = "C:\aaa\Inv" & Range("H4").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=NewFN, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Range("H4").Value = Range("H4").Value + 1
End Sub

2. There is also a problem when the quantity & unit price is equal to zero there is #VALUE! appearing on different areas!
Do you have the code for this?

Regards,
Louis
Attached Files

Extract Needed Data in Single Cell

$
0
0
Hi Guys,

I got a problem, In extracted CSV the file is not separated.

Like this one on a single Cell.

:vendor:014154 MEGA SOFT HYGIENIC PRODUCTS INC :tel:365-2728 :buyer:301 CONNIE AVILA :fax:365-2727 :dept:000 *ALL :subDpt:000 *ALL :terms:030 30 DAYS :currency:PHILIPPINE PESO :discounts: %:status:3:type:C:dlvLocation:00881 MERKADO SUPERMARKET :dlvAddress:B106 G/F UPTOWN Center Katipunan Ave. Brgy. UP Campus QUEZON CITY QC


I only need the dlvLocation: 00881 or the 00881 only.

Anyone can help me?

Thank you in advance

Excel VBA Macro - Limit based on cell selection

$
0
0
Trying to restrict a user from selecting from anything in 3 columns with a conditional formatted list

Target Range: (three columns L:N) i.e. L3, M3, N3 up to L40, M40, N40.

Unless a user first populates a field in Column U

Target Range: U3-U40

I've tried searching how to lock cell selection unless a corresponding cell is selected for the last few days to no avail. Think the issue is because the target cells aren't actually having a value entered and instead are using a list from conditional formatting.

Thanks! Andrew.

Enable check boxes on 2nd worksheet if check boxes on the 1st worksheet is selected

$
0
0
I want the checkboxes on the 2nd worksheet be initially disabled and only be enabled if the check boxes on the 1st worksheet are selected. For example, if denim is selected on the 1st worksheet, I want Denim in the 2nd worksheet to be enabled or have a checkbox. Either way is fine. Is there a code or I could do something in the properties for each checkbox.
Attached Files

Assign staff into groups based on some criteria

$
0
0
Good morning, I need some help here to get started. I have 3 workshop rooms to allocate staff evenly based on criteria such that it balances out the 'smart ones' (column F, Score), gender, country, agency and seniority (column E, title). The order of the criteria is in descending level of priority. In other words, the most important criteria is to ensure the average score in group 1 is comparable to group 2 and 3, then try to balance out the second, third, forth and fifth criteria. One thing to note is that we usually have around 27-31 staff per seminar, so the number of staff is not fixed.

Appreciate if anyone could come up with solution to 'automate' the allocation either through formula or macros :)

My initial approach is to randomly assign the staff, then 'sumif' for each of the 3 groups to check the average score, 'countif' for gender count, country count, agency count, and seniority count. I will press F9 until I observe a well balanced distribution in the 5 criteria. Having said that, I am sure there is a better way of doing this with some 'rules'. Appreciate your kind help.
Attached Files

[SOLVED] Group string based on comma using regex

$
0
0
Hello everyone

Say I have string separeted by comma like
Yasser, Ahmed, Reda, Khalil
How can I group each part of those words within string using regex pattern?
I am searching for something similar to (\,.*)(.*\,) but this is not right

so I can isolate the strings using regex like that
Yasser
Ahmed
Reda
Khalil

Thanks advanced for help

New to Excel and want to know more about VBA

$
0
0
New to Excel and want to know more about VBA

Extract text from a cell without the last string after some character.

$
0
0
Hi Guys, I have this Text inside of "A1" cell "Josh.Strap.12" "A2" cell "Rina.Gomz.123" "A3" cell "Gonz.Gre.1234"

I need to get in the "B" cell the name without the characters after the last dot "." character
IE.
Cell A1 Josh.Strap.12 Cell B1 Josh.Strap
Cell A2 Rina.Gomz.123 Cell B2 Rina.Gomz
Cell A3 Gonz.Gre.1234 Cell.B3 Gonz.Gre

Any idea?

empty row between colours

$
0
0
Hi all,
In column D, I have the name of a colour. The colour will repeat over a few rows i.e 6 0r 7 somtimes more.Then there will be a different colour for the next few rows and so on.
Is there a way that when the colour changes I can place an empty row on the sheet.
Any suggestions most welcomed :)
Kind Regards
BIF

Macro to update data in a table on master data sheet?

$
0
0
I got a macro from Eastw00d (massive thanks :-) ) which pulls data from sheets into a master data sheet and it works perfectly
until I change the format to a table so that I can use a slicer on a dashboard page.
Can anyone have a look at the macro and change it so that it works with the table or alternatively suggest another way to have a function like a
slicer on the dashboard?
Viewing all 50199 articles
Browse latest View live