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

Data not showing up in worksheet when hitting save(add) button when runnin macro

$
0
0
Hello, first time here and new to VB. Ok here is what I have, Have form with labels, text box and command button. When I hit the save button after entering data it does not enter it into worksheet and I do not get any error messages as to saying the code is not working. Have 3 text boxes and labels, 2 command buttons, 1 for saving and 1 for exiting. What I am trying to do is enter data into worksheet, save it and next time it enters in next row and so forth.

Thanks, Mike

Merge two macros together to make them work with each other

$
0
0
Hi,

I need to merge to Macros to work with each other.

The first Macro grabs names in a cell range then makes new tab names with the names in those cells -

Sub Invoices_Add_Named_Tabs()
Dim MyCell As Range, MyRange As Range

Set MyRange = Sheets("Address").Range("A2")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

For Each MyCell In MyRange
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
Next MyCell
End Sub

The other macro copies a sheet and all its data into a new sheet -

Sub Invoices_Add_Invoice()
Dim x As Integer

x = InputBox("Enter number of times to copy Sheet1")
For numtimes = 1 To x
'Loop by using x as the index number to make x number copies.
'Replace "Sheet1" with the name of the sheet to be copied.
ActiveWorkbook.Sheets("Invoice").Copy _
After:=ActiveWorkbook.Sheets("Address")
Next
End Sub

I need the macro to make a new sheet according to the names in the cell range, and copy into each of the new tab the data from sheet "Invoice", so one month i may have 8 names, then the next month may have 16 names.

so for example if there is 8 cells to be made into 8 named tabs, then each of the 8 newly made tabs will have the same data from the sheet "Invoice"

if there are 16 cells to be made into 16 named tabs, then each of the 16 newly made tabs will have the same data from the sheet "Invoice"

Thank You in advance

how to delete sheets if cell value match

$
0
0
I have the following code to delete sheets, sheets with cell value lesser than a value will get deleted, I want sheets "PList", "sheet1" to "sheet 4" NOT to be deleted, and sheets with H9 value < "Plist".range B9 value be deleted, how to modify the code below, it deletes Plist and sheet1~4, i want to keep them, thanks for help

Code:

Sub Remove_Sheets()
 
    Dim i As Integer, bp As Long
    Dim ws As Worksheet
   
    Application.DisplayAlerts = False
    On Error Resume Next
    bp = Sheets("PList").Range("B9").Value
    For i = Worksheets.Count To 1 Step -1
    Sheets(i).Select
    If Range("H2").Value < bp Then
    If ws.Name <> "PList" And ws.Name <> "Sheet1" And ws.Name <> "Sheet2" And ws.Name <> "Sheet3" And ws.Name <> "Sheet4" Then
    Sheets(i).Delete
    End If
    End If
    Next i
    Application.DisplayAlerts = True
   
End Sub

Attached Files

lotus macro to excel

$
0
0
Lotus macro allows "/cdate~~{edit}{l 2}{?}~" when entering into an accounts macro. How can I do this in VBA?

Macro to select filtered data is inconsistent..

$
0
0
Dear Excel Experts,

I've been trying to find solution for this for almost a week but to no avail. Just really don't understand which part I've done wrong. :(

My code below should do copy to filtered data and paste them below the row (skip one blank row to differ) of the original data. The original data is in csv format which located in separate workbook. It has a checking command line to ensure that the filtered data is not blank, else skip and run next sub macro. This is needed to run through thousands of original data in separate workbooks. The weird thing that happens is that some files, the macro detects blank correctly, some won't and will prompt the error and stops the macro. I tried to change between count and countA for detecting the filtered data rows but if i do that the result will also be different, as if some of it is detected as text so, it will count in CountA but some will only be counted if using Count.. :( I have tried different version of Excel, ranging from 2010 up to 2016 but no difference.. :( I have tried many different macro commands to count only visible data rows but still don't give any difference.

This has been so much pain for me as I need to get accurate data to calculate SLA performance of each staff in attending tickets. Please, please, please help me.. :(


Code:

For Each Sheet In ActiveWorkbook.Sheets
'Call tukardate
Columns("D:E").NumberFormat = "@"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
    Selection.AutoFilter
    Range("A1").Select
    'LRow = Range("A" & Rows.Count).End(xlUp).Row
    LRow = Range("A1", Range("A1").End(xlDown)).Rows.Count
    'MsgBox LRow
    Set r = ActiveSheet.Range("$A$1:$F$" & LRow)
    r.AutoFilter Field:=5, Criteria1:=Array("PREPAID_SUPPORT", "28882"), Operator:=xlFilterValues
   
    'r.AutoFilter Field:=4, Criteria1:=Array( _
        "V03658X", "V01553X", "V03477X", "V03751X", "V03752X", "V04046X", "V04047X"), Operator:=xlFilterValues
   
   
    'LR = Range("A" & Rows.Count).End(.xlUp).Row
    'Range("A2:P" & LR).SpecialCells(xlCellTypeVisible).Select

    'jcell = WorksheetFunction.CountA(r.Cells.SpecialCells(xlCellTypeVisible))
    jcell = WorksheetFunction.CountA(ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible))
    'MsgBox jcell
    'wcell = WorksheetFunction.Count(r.Cells.SpecialCells(xlCellTypeVisible))
    wcell = WorksheetFunction.Count(ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible))
    'MsgBox wcell
    'MsgBox jcell
    If jcell = 0 Or wcell = 0 Then
    'If wcell = 0 Then
    If ThisWorkbook.Worksheets("Macros").Range("M1").Value = "" Then ThisWorkbook.Worksheets("Macros").Range("M1") = "1st Filter To Re-export:"
    MyRow = ThisWorkbook.Worksheets("Macros").Range("M" & Rows.Count).End(xlUp).Row
    'MsgBox MyRow
    ThisWorkbook.Worksheets("Macros").Range("M" & (MyRow + 1)).Value = FileName
    MyRow = ThisWorkbook.Worksheets("Macros").Range("M" & Rows.Count).End(xlUp).Row
    ThisWorkbook.Worksheets("Macros").Range("$M$1:$M$" & MyRow).RemoveDuplicates Columns:=1, Header:=xlYes
'End If
    GoTo OtherFilter
   
    End If
    Range("A2:F" & LRow).SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Rows((LRow + 2) & ":" & (LRow + 2)).Select
    ActiveSheet.Paste
   
    Selection.AutoFilter

GoTo OtherFilter

OtherFilter:
    'Range("D1").Select
    'Selection.AutoFilter
   
    Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
    Selection.AutoFilter
    Range("A1").Select
    'LRow = Range("A" & Rows.Count).End(xlUp).Row
    LRow = Range("A1", Range("A1").End(xlDown)).Rows.Count
    'LRow = LRow - 2
    'MsgBox LRow
    Set r = ActiveSheet.Range("$A$1:$F$" & LRow)
    r.AutoFilter Field:=4, Criteria1:=Array( _
        "V03658X", "V01553X", "V03477X", "V03751X", "V03752X", "V04046X", "V04047X"), Operator:=xlFilterValues
    'r.AutoFilter Field:=5, Criteria1:=Array("PREPAID_SUPPORT", "28882"), Operator:=xlFilterValues
   
    'r.AutoFilter Field:=4, Criteria1:="V04047X", Operator:=xlFilterValues
    'kcell = WorksheetFunction.CountA(r.Cells.SpecialCells(xlCellTypeVisible))
    kcell = WorksheetFunction.CountA(ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible))
    'MsgBox kcell
    'vcell = WorksheetFunction.Count(r.Cells.SpecialCells(xlCellTypeVisible))
    wcell = WorksheetFunction.Count(ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible))

    'MsgBox vcell
    'MsgBox kcell
    If kcell = 0 Or vcell = 0 Then
    'If vcell = 0 Then
    If ThisWorkbook.Worksheets("Macros").Range("N1").Value = "" Then ThisWorkbook.Worksheets("Macros").Range("N1") = "2nd Filter to Re-export:"
    MyRow1 = ThisWorkbook.Worksheets("Macros").Range("N" & Rows.Count).End(xlUp).Row
    'MsgBox MyRow1
    ThisWorkbook.Worksheets("Macros").Range("N" & (MyRow1 + 1)).Value = FileName
    MyRow1 = ThisWorkbook.Worksheets("Macros").Range("N" & Rows.Count).End(xlUp).Row
    ThisWorkbook.Worksheets("Macros").Range("$N$1:$N$" & MyRow1).RemoveDuplicates Columns:=1, Header:=xlYes
    GoTo OtherWsheet
    End If
   
    'Range("A" & LRow + 1).Select
   

    'cnt = Range("A" & (LRow + 2)).CurrentRegion.Rows.Count
    'MsgBox cnt
    'MsgBox LRow
    'nxtr = LRow + 1
    'MsgBox nxtr
    'LRow = LRow - 2
    Range("A2:F" & LRow).SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    'cnt = LRow + 3
    LRow = Range("A" & Rows.Count).End(xlUp).Row
    'MsgBox cnt
    Rows(LRow + 1 & ":" & LRow + 1).Select
    'Rows(nxtr & ":" & nxtr).Select
    ActiveSheet.Paste
GoTo OtherWsheet

OtherWsheet:
'MsgBox LRow
  Range("A1").Select
  Selection.AutoFilter
  LRow = Range("A1", Range("A1").End(xlDown)).Rows.Count
  'MsgBox LRow
  'LRow = Range("A" & Rows.Count).End(xlUp).Row
  'If Range("A" & LRow).Value = "" Then Rows("2:" & LRow).Delete Else Rows("2:" & (LRow + 1)).Delete
  Rows("2:" & LRow + 1).Delete
  ' Range("A2").EntireRow.Delete
    'Rows("2:2").Select
  ' Range(Selection, Selection.End(xlDown)).Delete
  ' Rows("2:2").Delete
  LRow = Range("A1", Range("A1").End(xlDown)).Rows.Count
    ActiveSheet.Range("$A$1:$F$" & LRow).RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6), Header:=xlYes
    LRow = Range("A" & Rows.Count).End(xlUp).Row
    Range("A1").Select

Running macros automatically and only when specific value is located

$
0
0
Hi,
I raised a previous forum entry to ask how I changed a value automatically - this can be found in the forum entry here.

I was provided some macro code listed below, which worked, but I am now asking for some tweaks also listed below and have been advised to post here as this forum category is dedicated for this reason

** Code provided by Developer on General Forum:

Sub Change_Status()
Dim ws As Worksheet
Dim r As Long, lastrow As Long
Set ws = Worksheets("All Resourcing")
With ws
lastrow = .Cells(Rows.Count, 2).End(xlUp).Row
For r = 5 To lastrow
If Now > .Cells(r, 6) Then .Cells(r, 10) = "Expired"
Next r
End With

End Sub

** Small Tweaks requested by myself to this code are below:

1) would you be able to change the code to run automatically if there is a change to the end date (column F) to a date to or past todays date, so that the Expired status is changed to "Requested".
2) would you be able to change the code to run automatically when we enter the workbook on open, or when a change is made to the end date to be after todays date
3) Would it be possible to only set the "Expired" status if a date is located in the column F, because this code is adding Expired where I have blank lines in my workbook (because my non test entry has multiple disciplines (Linux, Windows etc) with blank lines between them)

I hope that you could change the code accordingly to help me?

If you need anything else from me, please feel free to ask.

Thanks Rob :confused:

Userform to filter through a table and export

$
0
0
I am trying to make a userform that filters a table based on what the user inputs, and then anything in the table that matches would be exported into a new excel template workbook. Only problem is I have no idea where to start. I have the userform made, but not sure what code would work best. Any help is appreciated. There is about 15 different filter options.

Sort and Delete Data Based on Multiple Criteria Using Check Box in Userform

$
0
0
Hi All,

Is there anyone could help me in this group to fix my vba script, my problem is i already create 4 checkbox in userform, if i thick one or two checkbox (example : trim holes, and presplit holes), and click 'OK' button then the rows automatically deleted except criteria that i checked. Range that i want to check located in column "I".

Here's the script :

Code:

Private Sub OK_HolesType_Click()
    Dim varList As Variant
    Dim lngLastRow As Long, lngCounter As Long
    Dim rngToCheck As Range, rngFound As Range
    Dim rngToDelete As Range, rngDifferences As Range
    Dim blnFound As Boolean
    Dim cbox As Control
   
 
    Application.ScreenUpdating = True
 
    'change Sheet1 to the codename of the sheet you want to check
    With Sheets("Daily Drill Hole Report")
        lngLastRow = GetLastUsedRow(.Cells)
 
        'we don't want to delete our header row so we start from row 2
        'change the A's to the column letter you want to check
        Set rngToCheck = .Range("I3:I" & CStr(lngLastRow))
    End With
 
    If lngLastRow > 1 Then
 
        With rngToCheck
            varList = Array(cboxtrim.value, cboxpresplit.value, cboxlinedrilling.value, cboxrampgrade.value)
 
            For lngCounter = LBound(varList) To UBound(varList)
 
                Set rngFound = .Find( _
                                    What:=varList(lngCounter), _
                                    Lookat:=xlWhole, _
                                    SearchOrder:=xlByRows, _
                                    SearchDirection:=xlNext, _
                                    MatchCase:=True)
 
                'check if we found a value we want to keep
                If Not rngFound Is Nothing Then
 
                    blnFound = True
 
                    'if there are no cells with a different value then
                    'we will get an error
                    On Error Resume Next
                    Set rngDifferences = .ColumnDifferences(Comparison:=rngFound)
                    On Error GoTo 0
 
                    If Not rngDifferences Is Nothing Then
                        If rngToDelete Is Nothing Then
                            Set rngToDelete = rngDifferences
                        Else
                            Set rngToDelete = Intersect(rngToDelete, rngDifferences)
                        End If
                    End If
 
                End If
 
            Next lngCounter
        End With
 
        If rngToDelete Is Nothing Then
            If Not blnFound Then rngToCheck.EntireRow.Delete
        Else
            rngToDelete.EntireRow.Delete
        End If
    End If
 
    Application.ScreenUpdating = True
   
End Sub

Here's userform :

Problem.PNG


Thankyou in advance master.

Subquery problem takes so long paste data

$
0
0
Hi , I am using subquery for Retrieve Next record date (Get the value in another record) base tip of access from(http://www.allenbrowne.com/subquery-01.html#TopN) . My subqueries work fine in ACCESS and there is no problem but after using in excel takes so long for in line
Code:

.Range("A2").CopyFromRecordset rst
Please help me.

Find Data and Copy to Another Sheet

$
0
0
Hello,

I have a workbook with two sheets. The first one has data called Records and the second statements called Statements.

In the sheet Records column C has names. From time to time I need to generate a statement for a particular name. So the macro goes through each row and copies all the rows that match the name in the Statements sheet below the last record.

The below code has been working well. It has two limitations though:

(i) As the row numbers have increased to 4000+, it has started taking a long time to go through each row and copying them; so the question is if there is a better way of doing it faster;

(ii) Second, sometimes we don't remember the spelling of the names and it takes two three times (further complicated in cases of similar names) so is it possible that the macro creates a box with all unique names sorted alphabetically and lets you choose what you want; and

(iii) Finally Column D of Records has dates, is it possible to specify start and end date in addition to the name so that the records are copied only for those days. Right now it copies all rows and then we manually delete all rows above and below the range of dates we want the records for.

Thank you so much for all your suggestions and help.





Code:

Dim i, LastRow

' Put Todays Date in Statements
        Sheets("Statements").Select
        ActiveCell.SpecialCells(xlLastCell).Offset(2, 0).End(xlToLeft).Select
        ActiveWorkbook.Names.Add Name:="Tempo", RefersToR1C1:=ActiveCell
        ActiveCell.FormulaR1C1 = "=TODAY()"
        Selection.NumberFormat = "[$-409]d-mmm-yy;@"
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
       
' Start the search for the records and copy
    Sheets("Records").Select

    Counter = 0
    LastRow = Range("C" & Rows.Count).End(xlUp).Row
    sString = UCase(InputBox("Enter string to locate", "Search Criteria"))
    If sString = "" Then
        Exit Sub
    End If
    For i = 1 To LastRow
        If InStr(1, UCase(Cells(i, "C").Value), sString) Then

'Use the below line if you want to know where the String is located.
'MsgBox "'" & sString & "'" & " was located in cell " & Cells(i, "C").Address(0, 0), vbOKOnly, "Found"

'This is to copy the Row once found
        Range(Cells(i, "C").Address(0, 0)).Offset(0, -1).Select
        Range(Selection, ActiveCell.Offset(0, 9)).Copy
        Sheets("Statements").Select
        ActiveCell.SpecialCells(xlLastCell).Offset(1, 0).End(xlToLeft).Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False


        Counter = Counter + 1
        Sheets("Records").Select

        End If

    Next

ActiveX Controls: How to make a dependent list when Range is in a different sheet

$
0
0
Good morning

I have ComboBox1 (Stock Market) and ComboBox2 (Stock name), and I want the list in my ComboBox2 to be dependent on ComboBox1.
(i.e. I want ComboBox2 to show only stocks that are in the stock market chosen in Combobox1)


If my helping columns are in the same worksheet, my colleague told me to use the following code:

Code:

Private Sub ComboBox1_Change()
   
    Me.ComboBox2.Clear
    If Me.ComboBox1.Text = vbNullString Then Exit Sub
    Dim ListCell As Range
    For Each ListCell In Range(Me.ComboBox1.List(Me.ComboBox1.ListIndex))
        Me.ComboBox2.AddItem (ListCell.Value)
    Next ListCell
   
End Sub

However, when they are in different worksheets, it doesn't seem to work.

Thank you very much in advance!

Macro: check today date with start date and open a file in stored location

$
0
0
Hi all,

I would like to kindly ask you if someone of you could help me to create a marco for the next.

I have a classic table (see attached addition) where is written start date/duration/forecast/completion/status.
I would like that the marco after open my excel file will always check the today date and compare it with start date. In case that this two dates will match it will automaticaly open a file in the location of my computer: C:\Users\tdubois\Documents . This macro should be able to open more files which are stored in the same location in case that today date will match with more start dates.

Thank you for all your help.

Regards
Attached Files

Excel Cells in to PowerPoint

$
0
0
Hi!

I am trying to get a VBA script which will allow me to click a button in my Excel sheet and sit back and enjoy the 3 second show!

What im after is the following:

In Cells B2:F14 I have a bunch of data in a specific order. When i click my Macrobutton in Excel I want Excel to open up Powerpoint, load the predetermined slideshow and page in the predetermined slideshow and paste the data (Cell format, size etc included) into the page.

Is this possible in a simple way?

Thank you in advance!

VBA Code Tweak

$
0
0
Hi all,

I have a Macro I'm using to tidy up a text export from another program. The line below looks for specific product codes, then extracts the various fields.

However, we have now introduced a whole host of new product codes which begin with a vast range of characters. Is there a way I tweak the first line of the code below to say thet "If there are any numeric values within the first eight characters of each line, extract"?

Code:


If (Left(Record, 8)) Like "C0*" Or (Left(Record, 8)) Like "BB*" Or IsNumeric(Left(Record, 8)) = True Then
           
            xCode = Trim(Left(Record, 8))
            Desc = Trim(Mid(Record, 14, 36))
            Unit = Trim(Mid(Record, 50, 7))
            Pack = Trim(Mid(Record, 57, 3))
            PriceType = Trim(Mid(Record, 63, 12))
            Price = Trim(Mid(Record, 79, 6))
            Break = Trim(Mid(Record, 86, 5))
            Review = Trim(Mid(Record, 96, 9))
            Effective = Trim(Mid(Record, 105, 10))
            LastSale = Trim(Mid(Record, 115, 10))

Many thanks in advance!

[SOLVED] Macro to find time by Hour

$
0
0
I need a macro that will look on Sheet 1 and find time by hour and insert the username of the current person logged in into the cell to the right.

The time on the sheet is in hour blocks so 01:00.... 02:00 and so on...

I attached a sample sheet but I'm not to sure where the times are going to be stored but I do know that they are going to be on sheet 1

Thank you for your help
Attached Files

Edit macro

$
0
0
Hi. The below macro that sourabhg98 created needs some changes. This macro "gives" me 1 when there is a rise of a certain % (cell "U2") from a low and "gives" me 2 when it loses a certain % (cell "S2"). I'm attaching my workbook. What I want to do now is the % change from a low to be a moving number and not a constant. So, instead of "U2" to have the cell in column I.
In this case, B7 is more than 4.55%(I7) from B5 so H7 should be 1 (the column that I want 1 and 2 to appear). 2 will be in H14 because the drop from B7 to B14 is more than 4.62%(I14).

Hope you understand what I'm trying to do!
Thanks for any help!

Code:

Sub Bear_events()
Range("H4:H20000").ClearContents
k = 4
p = 2
lt = 0.001
For n = 5 To Range("A" & Rows.Count).End(xlUp).Row
lmin = Application.Min(Range("B" & k & ":B" & n - 1))
If (Range("B" & n).Value - lmin) / lmin >= Range("U2") And p = 2 Then
Range("H" & n).Value = 1
k = n
p = 1
lt = Range("B" & n).Value
ElseIf (Range("B" & n).Value - lt) / lt <= Range("S2") And p = 1 Then
Range("H" & n).Value = 2
k = n
p = 2
End If
Next n
End Sub

Attached Files

Control if all checkboxes are FALSE (then...)

$
0
0
Hi, I'm new to this forum and a newbie to coding with vba. I've searched the net for a solution for my current problem, but haven't found any suitable solution yet. Maybe some of you here can help me. Ok, to the topic: I have a set of checkboxes (form control) and I'd like to write a vba code to control if all checkboxes are FALSE (or value = 0). If so, I simply want a MsgBox to appear and then Exit Sub. I've written a code that goes loops through all checkboxes, but it doesn't give the desired end result if all checkboxes are FALSE. Here's the code I have so far:

For Each cb In ActiveSheet.Shapes
If cb.Type = msoFormControl Then
If cb.FormControlType = xlCheckBox Then
If cb.ControlFormat.Value = 0 Then
iX = iX + 1
If iX = 0 Then
MsgBox "No checkboxes are selected"
Range("B3").Select
Exit Sub
End If
End If
End If
End If
Next cb

Any ideas?

Cheers,
Magne E.

Import Data From Multiple CSV's and Append into Single Sheet

$
0
0
I have a series of comma delimited CSV files which I need to import on a regular basis and would like to automate the process.

The number of files I import varies from 1 to 20 but their structure are identical except for the content. The data I need to extract starts at line 9 and can vary between 1 and 300 lines within the file.

I recorded a macro but I am now stuck as to how I can get this to loop through each of the files and append the data to the bottom

Code:

    Sheets("MasterCSV").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\Temp\BBs\Data_1.csv", _
        Destination:=Range("$a$1"))
        .Name = "Data_1"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 850
        .TextFileStartRow = 9
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With

Any assistance in this matter would be greatly appreciated.

Thanks

Delimited Text To Columns Utlizing a User Form Text Box Can't Manually Enter Data

$
0
0
Hi all I am having a problem with Parse data error message when entering data manually or scanned into a user form. If I paste the same data from the clipboard it works fine. But if I try to manually enter it or scan it, I get the run time error 1004, "No Data Was Selected To Parse". It scans the data letter and digits precisely but it will not work, unless its coming from the spreadsheet/clipboard. I know its looking at selection, im sure that's where the problem lies I just dont have the know how, the macro was recorded Here is the code:

Private Sub CommandButton1_Click()

Selection.TextToColumns Destination:=Range("L2:M2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 9), Array(4, 9)), _
TrailingMinusNumbers:=True

End Sub

my raw data looks like this: ELRTY10-8888753-prf-16095
Ultimately in cell L2 "ELRTY10" and "8888753" in cell M2

that's the reason for the text to columns to erase the rest not needed. Again Clipboard Ctrl V works but manually or scanning into the user form text box gives the error.

Copy Paste Certain Rows on a condition Macro

$
0
0
Hie All,
So basically i am making invoices from a master file where all the necessary inputs are there, what i want is automation of the invoices, the master file contains the following data:
B2 C2 D2 F2 G2 J2 K2 L2 M2 P2 SrNo Date Quot Date Inv Product StockC ProdcutC Qty Price
And the file where it should be pasted is, as follows in Sheet-1:
C8 G8 B25 G27 H27 C32 C33 C2 D2 J2 M2 P2 K2 L2
And In Sheet-2:- E8 E10 F2 G2
And also all these should be pasted special as only values not as links,
So far what i have made the code is it would get the desired values from all those and paste special from the master file for row 3.
What i want is when i run the macro in the blank invoice sheet, it would ask me enter SrNo which would be from column B, and when i enter 1, it would look for SrNo=1 and then extract the data from the above and paste it as above.
Also The file name in which these data would be pasted would be changed, for instance for Sr No 1, the file would be 1INV.xlsm, for Sr No 2 it would be 2INV.xlsm and so on..
Thanks All,
Viewing all 49906 articles
Browse latest View live