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

[SOLVED] Delete whole row

$
0
0
Hi Guys,

I need a small help from you guys, I have a excel file where i am importing data from different files. What i need is to delete the whole row when the user write "Done" on the last column called 'AT'.

Like this:

Name ID Status

Abdul 1 Done
Rag 2 Done
Roh 3 Undone
Zai 4 Done

So the result would be like this

Roh 3 Undone.

When we run the macro.

Kindly help me in this matter.


There is another post going on with the same Question.

here is the link .

http://www.mrexcel.com/forum/excel-q...matically.html

Cut and paste to another column

$
0
0
I have the data 1 To 100 from A1 to A100.... i trying to do that if the row count more than 25, the entire row data will move to column B..anyone can help?

Listbox value to multiple columns

$
0
0
Hello friends,

Please help me for macro code.

How to vba listbox value transfer/copied to multiple columns/rows in worksheet?

I have attached a file for your reference.

List Box.xlsm

I need to enter the values in next row if values are entered in row.

$
0
0
Im generating the report daily. using everyday report i need to prepare the graph.
so every day same field are getting updated. Instead i need to update the values in next row.

for eg.

there is data in c5 to h5. next day while running the macro the values should be updated from c6 to h6

please help me ASAP.....

i have attached the excel ... please verify...



thanks in advance .
Attached Files

help with code to create a new sheet each quarter

$
0
0
My goal is this:
Macro to run every 3 months, copy the workbook its in, save as a new name, and then delete all of the tabs in the workbook except for the "Menu" tab?

however. I get errors with my code below. Could anyone help me test / fix the code?


Code:

Sub SaveIfThreeMonths()

'Assign the month # of a year quarter that you want this to run to QtrMonth
'1, 2, or 0
'Ie: 1 = Jan, Apr, Jul, and Oct
' 0 = Mar, Jun, Sept, Dec

Const QtrMonth As Long = 1

Const MyPath As String = "J:\Groups\BSHEETS\SDA\EOD HISTORY\" 'Full path to folder with trailing backslash
Dim MySavedName As String
Dim sht As Worksheet

MySavedName = ActiveWorkbook.Name & " - " & Format(Date, "yyyymmm") & ".xlsm" '(MyName.xlsm - 2014Jan.xlsm)
 
  If Not (Month(Date) Mod 3) = QtrMonth Then Exit Sub
  If Not Dir(MyPath & MySavedName) = "" Then Exit Sub 'already saved this month

  Application.DisplayAlerts = False
 
  ActiveWorkbook.SaveAs MyPath & MySavedName
 
  For Each sht In ActiveWookbook.Sheets
    If sht.Name <> "Menu" Then sht.Delete
  Next sht
 
  Application.DisplayAlerts = True
  ActiveWorkbook.Save
  ActiveWorkbook.Close

End Sub

Opening only xlsx files

$
0
0
Hi All,

My current code will open and compile all my required cells to a Master document and all works fine until I come across another file type, my problem is I need to only open files of a xlsx type, my current code will try to open any file beginning with PJ, even a doc file, how can I alter to code to only open xlsx files?

<Code>
Sub OpenFilesInAllFolders(ByVal SourceFolderName As String, ByVal IncludeSubfolders As Boolean)
Dim FSO As Object
Dim SourceFolder As Object
Dim subfolder As Object
Dim FileItem As Object
Dim LR As Long
Dim ws As Worksheet

Set ws = Sheets("Sheet1")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FSO.GetFolder(SourceFolderName)

For Each FileItem In SourceFolder.Files
If Not InStr(FileItem.Name, "Master") = 1 _
And Not InStr(FileItem.Name, "~$Master") = 1 _
And InStr(FileItem.Name, "PJ") Then
Workbooks.Open SourceFolder & "\" & FileItem.Name

' ActiveSheet.Range("A83").Value = "Compiled"

If Not ActiveSheet.Range("A83").Value = "Compiled" Then
</Code>

How to shorten code into an array to create a list of items separated by commas

$
0
0
I want a cell to be populated with words in other cells to create a list like this: "Apple, Pear, Banana, ETC...." I have created code that I am pretty sure will do this but it is very long and very messy. The one cell is being populated by multiple cells which hold a different word e.g a different fruit name. I need an Array which puts them all into the same cell separated with a comma. "lngWriteRow" can be ignored for now this just tells the code to input the list in the next empty row of column "E". Here is the code I have currently come up with:

Code:

ws.Range("E" & lngWriteRow) = ws.Range("L8").Value & ", " & ws.Range("M8").Value & ", " & ws.Range("N8").Value & ", " & ws.Range("O8").Value & ", " & ws.Range("P8").Value & ", " & ws.Range("L11").Value & ", " & ws.Range("M11").Value

Multi-Worksheet ActiveX Textbox to ActiveX Textbox Concatenate

$
0
0
My original problem, which was solved by Kenneth Hobson, I needed to concatenate two ActiveX text boxes together. It was for a spreadsheet to track server data and domain data.


Code:

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
 If KeyCode = 13 Then ChangeTextBox1  'Enter Key was pressed.
End Sub

Sub ChangeTextBox1()
  TextBox1.Value = Split(TextBox1.Value, ".")(0) & "." & TextBox2.Value
End Sub

Private Sub TextBox2_LostFocus()
  ChangeTextBox1
End Sub

Special Thanks to forum user Kenneth Hobson for his previous assistance


However, I have run into a small issue with using it that I'm not that skilled at altering the syntax of the code. I've tried to use ActiveSheet and Worksheet("Name") commands, but I cant get my version of the altered code to do what I need. I feel as though there is an easier way to accomplish this task, but the solution eludes me.


Nonetheless, could someone please point me in the right direction so that I can "link" two ActiveX Textboxes in the same Workbook, but in separate worksheets? To help explain further, see below:


Worksheet Project Details has an ActiveX textbox "CustomerName"
The "CustomerName" ActiveX textbox needs to share the data inputed on the Project Details worksheet with the Network Setup worksheet, which contains the "NetSetCustName" ActiveX textbox.

loop, do while, with variables - help

$
0
0
hi all, due to my limited knowledge and experience with loops i am hoping to get some help to further my abilities. i have 36 variables...some have values and some dont. this changes based on input. so for example, this time cpn1 may = " test ", but next time may = nothing. what i am looking to do is loop through variables cpn1 - cpn36 and if the variable has a value, copy that value to the last used cell in a column. its not much but i have this:

Code:

Sub chkcopy()
Dim i As Integer
Dim ichk As Integer
ichk = 36
For i = 1 To ichk

Do While i < 37
   
End Sub

thank you for any input !!!!

Opening another file from excel, when the file has been moved

$
0
0
Hi, I'm trying to create a macro that will open an excel file from an action button. the code would need to do the following:

1. Open a file stored at a designated location

2. If the file has been moved, the user would need to be prompted to navigate to the new file location

3. the new file location would then become the default location.


What I have so far is this:


Private Sub OpenSavedFile_Click()

Dim FilePath As String 'this is the location where the file is currently stored

FilePath = Cells(42, 1).Value ' This is the cell on the worksheet where the filepath is written

On Error GoTo ErrorHandler
Workbooks.Open FileName:=FilePath

ErrorHandler:

'in here would be the code in case the file has been moved. it would need to do the following:

1. Tell the user to navigate to the new file location
2. Automatically copy the new file path into the cell where the file path is referenced in the first part of the code
3. Open the file from the new location

End Sub

If any one can help that would be much appreciated!

Thanks!

Open a website and input text in search box

$
0
0
Hello - I am posting this in this forum because I did not get any help in the VBA forum. Maybe here I will :)

I have a new problem to solve. I have an Excel sheet with about 1,000 rows. Each row has an origin and destination column. Now I need a code that opens a specific website and goes to a specific tab and then search for the origin and destination fields queries. The code then takes each row and place them in the search query. The result from each row can result a valid connection between an origin and a destination OR no connection exists. So simply if connection is successful, the code simply returns "yes" otherwise "no".

I can open the website from Excel, but what I need to click on specific tab where I do my searches. One of the problems I am facing is that when I try to click on the tab I need I get the message that I must use Internet Explorer or Chrome or Mozilla. Although Excel uses Internet Explorer to open the website. I am not sure why this error.



Attached you will find the following:

1 - Few data rows that we need to run the loop on.

2 - A snapshot of the website that we need to input the data from the rows (FOLLOW LINK)

3 A snapshot to show you the tab ("Ocean Schedule") that we need to access after we open the main website in vba. (FOLLOW LINK)

https://www.dropbox.com/sh/7v0cc86qp29mkww/yrtJtTz02F


Any suggestion?

Thanks
Attached Files

Macro to Count Worksheets

$
0
0
Looking to provide some WB stats on the first page.

Textbox1 = Count of WS excluding "Sheet1", "Sheet2", "Sheet3"
Textbox2 = Count of WS excluding "Sheet1", "Sheet2", "Sheet3" with cell F3= "Compliance"
Textbox3 = Count of WS excluding "Sheet1", "Sheet2", "Sheet3" with cell F3= "Program"
Textbox4 = Count of WS excluding "Sheet1", "Sheet2", "Sheet3" with cell F3= "Performance/Field"

Thanks for any help in advance.

VBA to Create Permutations of different rows

$
0
0
Hello all,

I have been looking for resources to answer this question for some time now but none have been quite exactly what I need. I am currently learning the VBA language and need some help on a simple permutation problem that will most likely requires nested loops. I need a list of every possible permutation of words in a row broken out by column. Order does matter and not every row has the same number of words in it. Any help would be very much appreciated! I have attached a sample worksheet with a sample table and then the needed output format. Thank you!
Attached Files

macro to move selection to sheet 3 if...

$
0
0
Help please!

I have a load of records, each record on its own row, that now differ slightly and visually and formula wise it's become a nightmare.

to resolve it, what i want to do (in english sentences) is:

Sheet 1 - Select cell in column B of the record.
If corresponding cell in column J has "00:00" [a time] in it
move contents of cells B:J and L:N of that record row to Sheet 3
(clearing the contents on Sheet 1)

I want to be able to click a macro-assigned autoshape to initiate the "Move" once i have selected the first cell.

on sheet 3... once the info is moved over... can I have an automatic popup userform with a combo box to populate Cell K in Sheet 3 (different to sheet 1)
[I have the userform already, so i imagine it would be a line in the code to call.userform"Banding" (where the combobox options are 1-4)


can anyone help with the code please?

vba is not working on specific condition

$
0
0
hello everyone,I am having a problem with my macro.when I enter name of a worksheet on tracking sheet,its copies row to its named ws,but when I copy a row from data sheet to tracking sheet ,from tracking sheet it does'nt copy to sheet named "ross".
Attached Files

Excel 2010 VBA to Perform VLOOKUP Using Specific Cell in Active Row

$
0
0
Hello Forum and thanks in advance...

I am working on a planning tool in Excel 2010 for work and attempting to build in some informational displays in shapes (call them Shape 1 and Shape 2) that I've inserted on Sheet 1 at the top.

What I'd like the VBA code to do is have the shapes display information looked up from an array in another sheet (call it Sheet2!G1:O25) that houses text based data/info. The lookup must be based on the value of the column E in the active row on Sheet 1. If there's no value in the active row to perform the lookup with, then the shape displays "No Value Selected". If the lookup errors out because the value is not found in the Sheet 2 array, then display "Cannot Find Value".

The lookup should be performed anytime the user changes rows. (alternative if that's an issue, we could employ a "Display" command button)

Any assistance is greatly appreciated!

Best regards,
Chris

Filter data using Array Function

$
0
0
hello
i m using array function in my below formula...but there is an debug error
what going wrong

Code:

Sub FilterNames()

Worksheets("ENTRY").Range("ALLTABLE").AutoFilter _
Field:=3, Criteria1:=Array(">=", "=") & Worksheets("ENTRY").Range("C8") _
, Operator:=xlAnd, Criteria2:="<=" & Worksheets("ENTRY").Range("C8")
Range("C9").Select

End Sub

splitting rows

$
0
0
I need to split one row of data into multiple rows. I have one column which consists of a list of companies and Next to it I have a series of attributes for every year. I need to transpose the years into a single column and next to each year I need the values of the attributes. Please have a look at the attached file.
Attached Files

How do you declare several variables?

$
0
0
Let's say I want to declare variables a, b, c, d, e as integers. Can I do this?

Code:


Dim a, b, c, d, e As Integer

Or must I separate and do the following:

Code:


Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer

I know with String, I must declare each variable separately. Is this true for all objects (Worksheet, Workbook, Integer, Long, etc)?

How do you declare several variables?

$
0
0
Let's say I want to declare variables a, b, c, d, e as integers. Can I do this?

Code:


Dim a, b, c, d, e As Integer

Or must I separate and do the following:

Code:


Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer

I know with String, I must declare each variable separately. Is this true for all data types (Worksheet, Workbook, Integer, Long, etc)?
Viewing all 49956 articles
Browse latest View live