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

Help with Format if no formula

$
0
0
hello,
I have the following code and it works well, but if I apply a conditional format to any of the cells in the range, the code does not work because the conditional format takes over.
Is there a way for the code to take priority over any conditional format available in Excel?

Thank you :)

Code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each cl In Range("$A17:$I1500")
If Not cl.HasFormula And cl <> "" Then
    cl.Interior.ColorIndex = 5
End If
Next cl
End Sub


Macro to load text file not working.

$
0
0
Hi,

I need to load a text file into an excel, but to paste all only in the column A and not having to split them out to other column.

Here are the sample files:
HELP.xlsm
HELP.txt

If anyone can tell me where is wrong?

Thanks.

Copy only rows with data to second sheet (selected columns)

$
0
0
Hi guys,

Need help with my topic.....I'll explain further here.

- I have Sheet1 and Sheet2.
- Sheet1 has columns from A to AI and Sheet2 is pretty much a report on the top part and a reflective of selected columns from Sheet2 (below part)


My first question is:
- I need to copy and paste only columns A, B, AC and AD from Sheet1 to Sheet2 under column B, C, D, E starting from row number 33 (below part of the report). Only the cells with data to be copied.Template 2.xlsm
- Also on Sheet2, starting from cell A33, sequential number needs to be inserted [1,2,3...] for the identification of number of items.

Second question is:
I want to have those imported cells formatted with borders, so that when i print Sheet2, it will only print upto the part where cells contains data with borders.

I'll attach the file for your reference. Thank you so much in advance. Greatly appreciate any help.

Copy data based on datevalue

$
0
0
Hi I am trying to copy movie title from one sheet to another.
SCHEDULE is where I want the titles to show up and the movie should be the upcoming weekend movie. The movie comes from the MOVIES sheet.
On the SCHEDULE sheet I have column P that has random values of MOVIE and only in the Column Q, R, S, T I paste movie info.
I have one day working, but I want to rotate the Friday 21:00 movie or two movies on Saturday 18:30 and 21:00 or Sunday 21:00. I cannot seem to get the rotation going.
I have attached a file of the code and sheets, the code is on the MASTERCONTROL sheet Macro 1
Here is the code, and I think the way I am deciding which day of week to find friday etc is overdone.
Thanks
Dale
Code:

Sub Macro1()

 
 
  Dim dayWeekN As Variant
 
 
    ' GREATER THAN 1 HOUR
    'MOVIES
    'assign movie if LESS than 18:00
 With ActiveSheet
  '**********************SATURDAY****************************************************
  MPROM = Sheets("MOVIES").Cells(.Rows.Count, "L").End(xlUp).Row
  LR = Sheets("SCHEDULE").Cells(.Rows.Count, "L").End(xlUp).Row
    For a = 1 To 1000
 
    For m = 2 To MPROM
 
 If Sheets("SCHEDULE").Range("P" & a).Text = "MOVIE" Then
      If Weekday(Sheets("SCHEDULE").Range("C" & a).Value) = 2 Then
    dayWeekN0 = 4
    dayWeekN1 = 5
      dayWeekN2 = 6
    ' rdn = 1
End If
 If Weekday(Sheets("SCHEDULE").Range("C" & a).Value) = 3 Then
    dayWeekN0 = 3
    dayWeekN1 = 4
      dayWeekN2 = 5
    ' rdn = 1
End If
 If Weekday(Sheets("SCHEDULE").Range("C" & a).Value) = 4 Then
    dayWeekN0 = 2
    dayWeekN1 = 3
      dayWeekN2 = 4
    ' rdn = 1
End If
 If Weekday(Sheets("SCHEDULE").Range("C" & a).Value) = 5 Then
    dayWeekN0 = 1
    dayWeekN1 = 2
      dayWeekN2 = 3
    ' rdn = 1
End If

 If Weekday(Sheets("SCHEDULE").Range("C" & a).Value) = 6 Then
    dayWeekN0 = 0
    dayWeekN1 = 1
      dayWeekN2 = 2
End If

 If Weekday(Sheets("SCHEDULE").Range("C" & a).Value) = 7 Then
    dayWeekN0 = 6
    dayWeekN1 = 0
      dayWeekN2 = 1
      'rdn = 2
End If

 If Weekday(Sheets("SCHEDULE").Range("C" & a).Value) = 1 Then
If TimeValue(Sheets("SCHEDULE").Range("C" & a).Value) < TimeValue("21:00") Then

    dayWeekN0 = 5
    dayWeekN1 = 6
      dayWeekN2 = 0
      End If
      If TimeValue(Sheets("SCHEDULE").Range("C" & a).Value) >= TimeValue("21:00") Then
      dayWeekN0 = 5
    dayWeekN1 = 6
      dayWeekN2 = 7
      End If
End If
         

 
    If DateValue(Sheets("MOVIES").Range("J" & m)) - (dayWeekN1) = DateValue(Sheets("SCHEDULE").Range("J" & a)) Then
 
   
            If (Sheets("MOVIES").Range("L" & m).Text) = "18:30" Or (Sheets("MOVIES").Range("L" & m).Text) = "19:00" And Weekday(Sheets("MOVIES").Range("J" & m).Text) = 7 Then
 

     
              Sheets("SCHEDULE").Range("Q" & a).Value = Sheets("MOVIES").Range("B" & m).Text
              Sheets("SCHEDULE").Range("R" & a).Value = Sheets("MOVIES").Range("J" & m).Text & " " & Sheets("MOVIES").Range("L" & m).Text
           
            End If
           
          For mm = m To MPROM
           
         
            If Sheets("MOVIES").Range("L" & m).Text = "21:00" And Weekday(Sheets("MOVIES").Range("J" & m).Text) = 7 Then
 
              Sheets("SCHEDULE").Range("S" & a).Value = Sheets("MOVIES").Range("B" & m).Text
              Sheets("SCHEDULE").Range("T" & a).Value = Sheets("MOVIES").Range("J" & m).Text & " " & Sheets("MOVIES").Range("L" & m).Text
           
                m = m + 1
            End If
   
         
          Next
     
    End If
       
  '  End If
   
      ' Sheets("TTESCHEDULE").Range("P" & a).Value = "MOVIE"
        Sheets("SCHEDULE").Range("W" & a).Value = ""
              Sheets("SCHEDULE").Range("X" & a).Value = ""
                 
        'End If
       
  End If
   
   
  ' End If
 
  Next
  'a = a + 2
Next
End With
End Sub

Attached Files

remove duplicate in one sheet by comparing to other

$
0
0
Hi,

I want a macro which will remove the total records in "CHILD" sheet by comparing with "MASTER" sheet
based on the condition that if the data from columns A, C and D are totally match between two sheets

e.g. see record 14 in "CHILD" sheet which should be removed as it is matching with 3rd row of master sheet.

Advance thanks for your help
Attached Files

Issue with ActiveSheet.VPageBreaks(1).DragOff

$
0
0
Hi All,

I have a problem when i tried to run a macro with the following sentence "ActiveSheet.VPageBreaks(1).DragOff". Attached is the excel file that i'm using; do you know if something is missing?

I want to setup a print area from "B11" to "G74" or there is another way to set a print area with a macro for multiple sheets?

https://dl.dropboxusercontent.com/u/85562478/Recibo.xls

Hope you know the answer.

Thanks,

[SOLVED] AutoFilter - Test to see if any data present

$
0
0
Hello all

What is the simplest way of see if after a filter has been applied with a criteria, whether any data is visible using VBA?

Thanks

James

Code to move data from an entry table to a historical table by date.

$
0
0
In the attachment you will see an example of what I am trying to accomplish. What I am trying to do is find VBA code that is either specific to this worksheet or in a macro. When the sheet is opened I enter a date in B2. I then enter data into A7, B7, and C7. What I would like to happen is when the data is entered into A7, B7, and C7 the sheet goes and finds the same date that I entered in B2 and copies that data from A7, B7, and C7 into F7, G7, and H7.


Thank you and any help given is greatly appreciated.
Attached Files

Sheetoffset - alternatives ?

$
0
0
Hello,

I have macro for creating new sheets, with copy method. After creating sheets I use Sheetoffset UDF function to paste formula which displays value from cells in previous sheet.

This Sheetoffset function works, but looks like It's a hard-code operation, so my macro takes 10-12 seconds to finish. I'm trying to find a substitute for Sheetoffset function that would perform quicker. Without that function my macro finishes in around 3 seconds.


Formulas are simple, example fo AJ5 with sheetoffset :
Quote:

=sheetoffset(-1;A5)
Formulas need to be in range of AJ5:AJ318 with step 4, cells which need to be referred are in range A5:318 with same step.


Anybody have any better ideas ?

Copy from different sheets- data based on selection and paste rows in new sheet

$
0
0
Hi all,
I have 6 sheets.
Sheet 1 to 5 has data.
In column 1 I have date & in column 2 have names on each sheet.

Last sheet is called 'Report'

I am trying to do the following:
On Report sheet I have a text box to type date of report required and also combobox to select Name

- I select either name or date ( Only one selection)
-Then all data rows matching selection are copied From Sheets 1 to 5 and pasted in sequence one below the other in report sheet
-The headings also are copied
-between two data range ( say from sheet1 ... sheet2)... one row needs to be blank to demarcate.

I am exhausted as I have tried many combinations and it is not working.
Very challenging indeed

Any help or thought process please

kind regards :)
Attached Files

VBA code to copy selected Cells from one sheet to another without changing the format

$
0
0
I want the VBA script that copies Values from one sheet to another with same format

E.g Copy the Range N21:P35 from Sheet1 to Sheet2 to Range B2:D:36
Copy Range T21:V:35 from Sheet1 to Sheet2 H2:J36
Copy Range N40:P54 from Sheet1 to Sheet2 B41:D55 and so there are multiple such data and multiple range, Number of cells in Range is same for all.
However I do not want the unwanted cells to be copied,

copy emails from outlook into a folder

$
0
0
Hello,
I am sending e-mails through an Excel Macro.
I want the sent e-mail to be taken from Outlook “Sent Items” and copy it to a certain folder on my computer.
Could anyone advise?
Thanks

Copying data from multiple workbooks to 1 master workbook

$
0
0
Hi guys

Can anyone help with the following query I have?

I have around 41 workbooks to represent different football leagues which are all identical in layout. What I was wondering was, is it possible to copy/import data from a sheet in each workbook and populate a master list in another workbook?

I'm guessing that in itself it's not a problem for someone who knows what they are doing but a problem I can forsee is that as I need all the sheets data listed underneath each other then each copy/import data set needs it's own cells attributing. For example data from Premier league workbook will occupy rows 3 -12 and data from championship needs to occupy rows 13 - 24 and then data from League One needs to occupy rows 25 - 36 and so on.

I've attached the intended master list workbook and the premier league workbook.

All League Master Sheet.xlsx
Premier League.xlsx

Any help appreciated

Cheers

2007 to 2013 locked cells problem

$
0
0
Hi All

I had a vareity of macros set up on a couple of Excel 2007 documents - nothing fancy just opening another workbook and then opens a sheet for me to write data into the cells.

Upgraded to 2013 recently, the Macros work following conversion of the sheets to 2013 (using the standard convert function in excel) and changing the code to look for the right file type - however I cant type anything in any of the cells.

The workbooks are locked to protect the integrity of the sheets, but even unlocking them doesn't solve the issue.

I've searched all over and havent been able to solve this, has any one got any general idea of why this might be happening?

formula or vba help on vlookup to get latest date from multiple lookup value of SO's

$
0
0
Dear Experts

I have 2 set of columns A:B A contains So's No B contains Date's I want get vlookup result latest date through from multiple so's&Date(range A:B)...apply formula in G:G

For E.g
For single So's & Date

Multiple So's & Date
7021097935 06-03-2014 result 10-03-2014
7021097935 06-03-2014
7021097935 10-03-2014
7021097935 10-03-2014
7021097935 10-03-2014
7021066551 12-03-2014result 12-03-2014
7021066551 19-02-2014
7021066551 19-02-2014
7021066551 21-02-2014
7021066551 26-02-2014
Attached Files

Formating semi-structured data in excel with macros

$
0
0
I've been trying to find a vb macro or similar to format a data base of 100k rows

I have it in a .txt file so I've put it in excel and thought about a solution.

For example I thought about the possibility of taking out every row from the first [f_id] till the following [f_id] and then use excel itself to separate every row having for example "]" but I'm not quite sure how to do it.

Also it would be nice to have some kind of control just in case for some reason everything gets mixed up, for example [data b] in the column of [data c]

Help would be appreciated :) Thanks in advance!

Before

Code:

  Col A
1
2 [f_id] => 1
3 [data a] => bla bla bla bla
4 [data b] => bla bla bla bla
5 [data c] => bla bla bla bla
6                                      //here for example a extra row, but it can be between [data a] and [data b]
7 [data d] => bla bla bla bla
8 continue in another row bla bla bla
9
10 [f_id] => 2
11 [data a] => bla bla bla bla
12 [data b] => bla bla bla bla
13                                      //here a random extra row
14 [data c] => bla bla bla bla
15                                      //here another random extra row
16 [data d] => bla bla bla bla          //here sometimes you can find the content in different rows, the only clear thing is that is always between [data d] and the following [data something] or [f_id]
17 continue in another row bla bla bla 
18 even more rows for data d
19
20 [f_id] => 3
21 ...
22 ...
23 ...
24 etc..

After

Code:

  Col A  Col B            Col C            Col D            Col E
1 [f_id]  [data a]        [data b]        [data c]        [data c]
2    1    bla bla bla bla  bla bla bla bla  bla bla bla bla  bla bla bla bla continue in another row bla bla bla
3    2    bla bla bla bla  bla bla bla bla  bla bla bla bla  bla bla bla bla continue in another row bla bla bla even more rows for [data d]

IF conditions

$
0
0
Hi, I want to write conditions in a column and I was told to use Excel functions but there is a limit to conditions. Here is the problem:

There is a column of numbers (A) and I want to put conditions in the corresponding cells in column B. The conditions are:

IF 0<Ai<100 then write 50
otherwise IF 100<Ai<150 then write 52
otherwise IF 150<Ai<200 then write 54
...
...
...
...
I have 70 ranges and therefore 70 conditions.The conditions don't follow a pattern. The beginning of the range is 0 and the end is 8000. There are 1536 rows (A2 to A1538). I just want to know how to write several IF conditions after each other. The below are some ranges I want to write:


34-100 50.0
100-150 52.0
150-200 55.0
200-250 58.0
250-300 61.0
300-350 64.0
350-400 67.0
400-450 70.0
450-500 73.0
500-550 76.0
550-600 79.0
600-650 82.0
650-700 85.0
700-750 88.0
750-800 91.0
800-850 94.0
850-900 97.0
900-950 98.5
950-1000 100.0
1000-1100 100.0
1100-1200 102.5
1200-1300 105.0
1300-1400 107.5
1400-1500 110.0
1500-1600 112.5
1600-1700 115.0
1700-1800 117.5
1800-1900 119.0
1900-2000 120.0
2000-2100 120.0
2100-2200 122.5
2200-2300 125.0
2300-2400 127.5
2400-2500 130.0
2500-2600 132.5
2600-2700 135.0
2700-2800 137.5
2800-2900 139.0
2900-3000 140.0
.
.
.
.
Thanks a lot for Helping

IF conditions

$
0
0
Hi, I want to write conditions in a column and I was told to use Excel functions but there is a limit to conditions using functions. Here is the problem:

There is a column of numbers (A) and I want to put conditions in the corresponding cells in column B. The conditions are:

IF 0<Ai<100 then write 50
otherwise IF 100<Ai<150 then write 52
otherwise IF 150<Ai<200 then write 54
...
...
...
...
I have 70 ranges and therefore 70 conditions.The conditions don't follow a pattern. The beginning of the range is 0 and the end is 8000. There are 1536 rows (A2 to A1538). I just want to know how to write several IF conditions after each other. The below are some ranges I want to write:


34-100 50.0
100-150 52.0
150-200 55.0
200-250 58.0
250-300 61.0
300-350 64.0
350-400 67.0
400-450 70.0
450-500 73.0
500-550 76.0
550-600 79.0
600-650 82.0
650-700 85.0
700-750 88.0
750-800 91.0
800-850 94.0
850-900 97.0
900-950 98.5
950-1000 100.0
1000-1100 100.0
1100-1200 102.5
1200-1300 105.0
1300-1400 107.5
1400-1500 110.0
1500-1600 112.5
1600-1700 115.0
1700-1800 117.5
1800-1900 119.0
1900-2000 120.0
2000-2100 120.0
2100-2200 122.5
2200-2300 125.0
2300-2400 127.5
2400-2500 130.0
2500-2600 132.5
2600-2700 135.0
2700-2800 137.5
2800-2900 139.0
2900-3000 140.0
.
.
.
.
Thanks a lot for Helping

regular expression for password

$
0
0
Hi,

I want to apply regular expression for password

a) The first letter cannot be number
b) the password should have a combo of numbers letters and one special character
c) The password should begin with a big case letter

ListIndex - combobox

$
0
0
Hello,

I have Combobox on Userform, in which I have listed days of month. At the end of Userform initialize event, my code ends with :

Code:

CboDatum.ListIndex = 0
This ofcourse sets Listindex back to first day, but I want Listindex to remain where It was last If I close and reopen Userfom. How can I correct that ?
Viewing all 49844 articles
Browse latest View live