Posts by tmpollard

    Re: Trouble including paste special in macro


    Quote from Grimes0332;768820

    You need to explain. The additional code you posted uses ADO to get records using CopyFromRecordSet. There are no 'formats' to paste.


    Thanks for the comment, as you can probably tell I really don't know much about vba (just learning some stuff).
    In my original dataset it has borders around the data and some of the cells has red text. I was just trying to find a way that when it copies the data to paste it with the original cell formatting. Thanks

    Re: Trouble including paste special in macro


    The below code is placed in a function module.




    Option Explicit

    Hello,
    Wondering if there is anyway to include the paste formats and values into the below macro? Every time I try I get a Compile error, expected end of statement.


    Thanks


    Include This


    Code
    .PasteSpecial xlPasteFormats
    .PasteSpecial xlPasteValues




    Into this

    Code
    Sub TestGetValue2()
        GetData "C:\Test\ToBeCopied.xlsx", "Sheet1", "A1:D10", Sheets("Sheet1").Range("A1"), False, False
        
    End Sub

    Re: Applying this code to additional columns


    Thanks for your help.
    I added two more sets of columns to fill out my sheet. There was one issue with the code, every time I pressed delete to delete one of the numbers I get a run-time error '13'.


    The other thing I would like to do is for each grouping to perform a different type of calculation so:
    C&D would be addition
    H&I would be subtraction
    M&N would be multiplication
    R&S would be division


    Code works for columns C & D, want to make the code work for columns H & I. Thanks




    [ATTACH=CONFIG]68733[/ATTACH]

    Hello,
    Hoping I can get some help with a problem I'm having, below is a snipit of code from my worksheet_change code. The Case numbers reference columns R and S on my spreadsheet. I am doing simple division, S/R and post answer in Column Q. It works fine in I enter data in column R then Column S but If I enter data in Column S first I get a division by 0 error. I would like to prevent this as the end user of the spreadsheet may enter the values in any order.


    Can someone please help. Thanks


    Code
    Case Is = 19
     If Target.Value <> "" Then
     Target.Offset(, -2) = Target / Target.Offset(, -1)
     End If
     
     Case Is = 18
     If Target.Value <> "" Then
     Target.Offset(, -1) = Target.Offset(, 1) / Target
     End If

    Hello all,
    I would like some help with a macro that I have, I was able to create this formula that I entered into a cell and got the results I wanted.
    =IFERROR(INDEX({"Machine 1","Machine 2","Machine 3"},MATCH(LEFT(A2,4),{"5000","5001","5002"},0)),"")


    [ATTACH=CONFIG]66484[/ATTACH]


    When pasting this code into my macro I get the following error
    Compile error:
    Expected: expression



    Below is what my macro code looks like. Any help would be greatly appreciated. Thanks


    Hello all, I need help with a formula that will put a certain message in a cell depending on the first 4 digits of what is in another cell.
    Example, cell A1 has 636755747857 the first 4 digits are 6367 so put "Blue" in cell B1.



    There are about 20 combinations of the first 4 digits that will be unique so this is a shortened list. Thank You..



    636755747857 Blue
    636287561396 Yellow
    636869685747 Green
    636755747873 Blue
    636287561324 Yellow
    636869685740 Green
    636755747865 Blue
    636287561432 Yellow
    636869685754 Green
    636755747881 Blue
    636287561360 Yellow
    636869685733 Green

    Hello,
    Can I please get some help with a macro, I put the columns and rows in to better define what I'm looking for. The keys for me are column B and column D.


    Row 2 and row 3 have the same unit number whenever this is identified look at column D and only keep the row with the most current time. In this example row 3 would be kept and row 2 deleted from the spreadsheet.


    My spreadsheet will have up to 100000 rows of data. Thank you all.


    Tried to attach a spreadsheet but not sure I did it correctly, that's why I added the data here. Thanks


    [TABLE="class: cms_table_cms_table, width: 464"]

    [tr]


    [td]

    Column A

    [/td]


    [td]

    Column B

    [/td]


    [td]

    Column c

    [/td]


    [td]

    Column D

    [/td]


    [td]

    Column E

    [/td]


    [td]

    Column F

    [/td]


    [/tr]


    [tr]


    [td]

    Row 1

    [/td]


    [td]

    Green Jacket

    [/td]


    [td]

    Created On

    [/td]


    [td]

    Created At

    [/td]


    [td]

    Product

    [/td]


    [td]

    Grams Weight

    [/td]


    [/tr]


    [tr]


    [td]

    Row 2

    [/td]


    [td]

    Unit 1

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:00:40

    [/td]


    [td]

    A

    [/td]


    [td]

    71.907

    [/td]


    [/tr]


    [tr]


    [td]

    Row 3

    [/td]


    [td]

    Unit 1

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:23:56

    [/td]


    [td]

    A

    [/td]


    [td]

    264.216

    [/td]


    [/tr]


    [tr]


    [td]

    Row 4

    [/td]


    [td]

    Unit 2

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:02:48

    [/td]


    [td]

    A

    [/td]


    [td]

    71.907

    [/td]


    [/tr]


    [tr]


    [td]

    Row 5

    [/td]


    [td]

    Unit 2

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:24:04

    [/td]


    [td]

    A

    [/td]


    [td]

    264.216

    [/td]


    [/tr]


    [tr]


    [td]

    Row 6

    [/td]


    [td]

    Unit 3

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:03:02

    [/td]


    [td]

    A

    [/td]


    [td]

    71.907

    [/td]


    [/tr]


    [tr]


    [td]

    Row 7

    [/td]


    [td]

    Unit 3

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:24:12

    [/td]


    [td]

    A

    [/td]


    [td]

    264.216

    [/td]


    [/tr]


    [tr]


    [td]

    Row 8

    [/td]


    [td]

    Unit 4

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:03:17

    [/td]


    [td]

    A

    [/td]


    [td]

    71.907

    [/td]


    [/tr]


    [tr]


    [td]

    Row 9

    [/td]


    [td]

    Unit 4

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:24:23

    [/td]


    [td]

    A

    [/td]


    [td]

    264.216

    [/td]


    [/tr]


    [tr]


    [td]

    Row 10

    [/td]


    [td]

    Unit 5

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:03:30

    [/td]


    [td]

    A

    [/td]


    [td]

    126.255

    [/td]


    [/tr]


    [tr]


    [td]

    Row 11

    [/td]


    [td]

    Unit 5

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:24:35

    [/td]


    [td]

    A

    [/td]


    [td]

    464.887

    [/td]


    [/tr]


    [tr]


    [td]

    Row 12

    [/td]


    [td]

    Unit 6

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:03:44

    [/td]


    [td]

    A

    [/td]


    [td]

    71.907

    [/td]


    [/tr]


    [tr]


    [td]

    Row 13

    [/td]


    [td]

    Unit 6

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:24:47

    [/td]


    [td]

    A

    [/td]


    [td]

    264.216

    [/td]


    [/tr]


    [tr]


    [td]

    Row 14

    [/td]


    [td]

    Unit 7

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:03:56

    [/td]


    [td]

    A

    [/td]


    [td]

    71.907

    [/td]


    [/tr]


    [tr]


    [td]

    Row 15

    [/td]


    [td]

    Unit 7

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:24:58

    [/td]


    [td]

    A

    [/td]


    [td]

    264.216

    [/td]


    [/tr]


    [tr]


    [td]

    Row 16

    [/td]


    [td]

    Unit 8

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:04:14

    [/td]


    [td]

    A

    [/td]


    [td]

    71.907

    [/td]


    [/tr]


    [tr]


    [td]

    Row 17

    [/td]


    [td]

    Unit 8

    [/td]


    [td]

    5/1/2015

    [/td]


    [td]

    17:25:10

    [/td]


    [td]

    A

    [/td]


    [td]

    264.216

    [/td]


    [/tr]


    [/TABLE]