Posts by 5nizza

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

    Is it possible to include a variable in the line's name for GoTO statement?? Example:


    this is just simplified code of what I'm looking for. Year is consntatly changing, and there're lables for each year in the code.... I didn't want to write a long code like


    Code
    if year="2011" then GoTo Lable2011
    ElseIf year="2010" then GoTo Lable2010
    ElseIf year="2009" then GoTo Lable2009
    End If
    
    
    Lable2011:
    Lable2010:
    Lable2009:

    Hello everyone,


    Below is an example of the worksheet I'm currently working on. Currently, there're about 3000 records in the table. Here's what I would like to calculate, and having a hard time figuring out how:

    • For example, for August,2011 (column A) count how many items in column B is from January 2008. So,I'm ignoring dates comletely, only month and year are relevant. The answer should return number 2. Or if we counting it for for Feb 2011 it should return 2...
    • Same should work for all other month(and other dates) in column A. So for July,2011 the answer should be 0,and for June,2011 it should be 1

    [TABLE="class: grid"]

    [tr]


    [td]

    A

    [/td]


    [td]

    B

    [/td]


    [/tr]


    [tr]


    [td]

    Disposition Date

    [/td]


    [td]

    Commenced Date

    [/td]


    [/tr]


    [tr]


    [td]

    08/01/2011

    [/td]


    [td]

    01/01/2008

    [/td]


    [/tr]


    [tr]


    [td]

    08/01/2011

    [/td]


    [td]

    01/20/2008

    [/td]


    [/tr]


    [tr]


    [td]

    08/02/2011

    [/td]


    [td]

    02/03/2009

    [/td]


    [/tr]


    [tr]


    [td]

    08/03/2011

    [/td]


    [td]

    02/07/2010

    [/td]


    [/tr]


    [tr]


    [td]

    08/03/2011

    [/td]


    [td]

    02/03/2010

    [/td]


    [/tr]


    [tr]


    [td]

    07/03/2011

    [/td]


    [td]

    03/25/2011

    [/td]


    [/tr]


    [tr]


    [td]

    07/01/2011

    [/td]


    [td]

    05/04/2008

    [/td]


    [/tr]


    [tr]


    [td]

    06/01/2011

    [/td]


    [td]

    01/15/2008

    [/td]


    [/tr]


    [tr]


    [td]

    06/03/2011

    [/td]


    [td]

    05/01/2008

    [/td]


    [/tr]


    [/TABLE]




    Any idea how to calculate it? I tried everything from COUNTIF to different SUMs and other basic formulas....

    Re: Macro to delete rows containing multiple criteria


    I modified my code a bit:



    P.S.: You're gonna ask to add 4th item, aren't you? lol

    Re: Macro to delete rows containing multiple criteria


    here's my version

    Re: Macros stop functioning when workbook is password protected


    Well, I had a similar issue, which I wasn't able to research. I think the only way to buypass it, is to tell macro to unlock the workbook in the beginning, and lock it back again after it's done. But again, I'm not an expert. let's see what others think.

    Re: Clear range of cells with blanks but leave cells with data


    Quote

    What is the variant 23 used for?


    I don't know... sorry :)

    Quote

    I guess I should have previous said the blank cells are "". Would this make a difference?


    well...I'm a bit confused. Would you mind posting a sample of what you're working with?

    Quote

    As you can tell I am not familiar with SpecialCells.


    if you want to know more, you can read here and here

    Re: Clear range of cells with blanks but leave cells with data


    Quote

    I want to clear cells with blanks and leave the cells with formulas.


    do you mean you want to clear everything but leave formulas in? if true than you can use

    Code
    Selection.SpecialCells(xlCellTypeConstants, 23).Select
        Application.CutCopyMode = False
        Selection.ClearContents

    Re: Macro to compare columns move to new tab


    change it to

    Code
    ActiveCell.FormulaR1C1 = _
            "=IF(AND(RC[-10]>=" & rng1 & ",RC[-10]=RC[-9]),""true"",""false"")"


    btw, you don't need to enter number with equal(=) sing....just a number will do

    Re: Run macro in multiple worksheets and save sheets individually


    i changed it a bit..how about

    Re: Macro to compare columns move to new tab


    So, i tried pervious macro at work, and it worked...but i still changed it just in case...

    Re: Copy data from one workbook to another


    Quote

    I have two workbooks that I am opening with VB code


    I assume you were starting with the blank workbook with no data, where you would paste the code to open two workbooks

    Quote

    Example of a few of the cells that need to be copied are
    Workbook 1 Workbook 2
    B1 B3
    B2 B4
    B3 B5


    I understood that you want data from workbook 1(b1,b2,b3) and 2(b3,b4,b5) copied to that new worksbook...

    Quote

    When I add that to my code I get an error that says "cannot change part of a merged cell". What is this code supposed to do?


    and how am I suppose to know that you have some merged cells, when it's a first time you're mentioning it?

    Quote

    What is this code supposed to do?


    if you paste it in blank workbook, it opens workbook, it will open workbook 1 and 2 and copy cells specified above.

    Quote

    It seems backwards to me because it is opening up the destination file first and then the source file that contains the data second.


    Oh, so you're saying workbook QuoteTemplate.xlsm was the one you wanted to paste info from Quote.txt?

    Quote

    Did I not explain what I am trying to do clearly above?


    Unfortunately no.

    To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.

    The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.

    To attach your workbook, scroll down and click on the Go Advanced button, then scroll down and click on the Manage Attachments button.

    Re: Counting Out of Stocks


    I did a search and found following topic. I tested it on yours and it works

    Code
    =SUM(IF(FREQUENCY(IF(B2:K2=1,COLUMN(B2:K2)),IF(B2:K2<>1,COLUMN(B2:K2)))>=1,1))


    when you paste the code into the cell, don't hit enter, but CONTROL+SHIFT+ENTER.

    Re: Copy data from one workbook to another


    something like that? Just add path to your files and paste it in the code below instead of red text

    Code
    Sub test()
    Application.ScreenUpdating = False
    Workbooks.Open Filename:="[COLOR=red]C:\Users\...\Documents\QuoteTemplate.xlsm[/COLOR]"
    Range("B3", "B5").Copy ThisWorkbook.Sheets(1).Range("b1")
    Workbooks.Open Filename:="[COLOR=red]C:\Users\...\Documents\Quote.txt[/COLOR]"
    Range("B1", "B3").Copy ThisWorkbook.Sheets(1).Range("a1")
    Workbooks("Quote.txt").Close
    Workbooks("QuoteTemplate.xlsm").Close
    Application.ScreenUpdating = True
    End Sub