January 22, 2020, 1:51 pm
Hi,
I'm trying to create a macro for a list of stock items that are missing from different stores. If a stock item is missing from a particular store the shop is listed in the next column. I have attached a file to highlight what I mean. I want the macro to be able to pull through each store with the missing item into a sequential list if possible.
Thanks
↧
January 22, 2020, 4:30 pm
Hello,
This is brief: if anyone has any information on modifying ActiveX controls dynamically - brief explanation:
I want a sub that I can send any button, listbox, label etc . . . to - objects that share similar properties like font and color - so I can modify them during program execution.
I could write the rules for each object but that kinda defeats the point of automation.
Any help would be cool.
Happy night,
Shawn
↧
↧
January 22, 2020, 4:51 pm
I have a "Navigation UserForm on a project for 3 teams. I currently am using a single column ComboBox filing from a named range. It's used to set folders for saving reports generated by my main spreadsheet. Originally I was using the Supervisor-TeamLead as the name of the folder and the values in the range for the combobox. But with promotions/terminations...etc. That would not be wise. So what I want to do is use a second range, or even an array, to assign the value of 1, 2, 3 to the second column. Then store that in the string, based on user picking their "team." Currently the code I am using to load for the single column Combobox is as follows.
Code:
Set wsLoc = Worksheets("LookupLists")
For Each cLoc In wsLoc.Range("Teams")
With Me.CBteam
.AddItem cLoc.Value
End With
Next cLoc
So For example if the combobox has Bob's Team, Tom's Team, Jane's Team in column 1, then Column 2 would contain 1, 2, 3. If I selected Tom's Team from the list, then I want my variable CTRteam to = 2.
Thanks in advance.
↧
January 22, 2020, 6:07 pm
I have a sub that performs a variety of actions such as taking inputs from a worksheet and outputting to another as well as modifying a chart object. I want the sub to be "volatile" so that it evaluates whenever any changes are made to the workbook. I've tried to make it both a Function and a Sub that is called by a separate volatile function but the end result is the same. For some reason the sub appears to exit early unless I call it from the Developer tab and not when a change is made on a worksheet however I don't want to do that since I want the evaluation to be automatic.
I've attached a simplified version of the workbook and the "exiting early" issue can easily be seen if breaks are placed on the three lines that output to the "K" worksheet.
As a second issue, the breaks also show that the sub evaluation isn't straight through and is bouncing from one line to another for some reason.
↧
January 23, 2020, 11:24 am
I would like a bar that would show in a series of dates, which day it is. Please see the attached excel document for what I'm looking for.
Thank you!!
↧
↧
January 23, 2020, 11:39 am
This might be a dumb question, and searching I can't find the answer. As everything is related to the "prompts."
What I am wondering is if there is a way to suppress the save progress/cancel box that comes up while the workbook is saving. There are no standard prompts to deal with. I've tried using the .screenupdating and .displayalerts (Both set to false before close and back to true after close). But it is still shown.
Like I've said, this may be one of the few displays you can't suppress. But wanted to see if I was missing another option. Thanks.
↧
January 23, 2020, 12:55 pm
Hey Everyone,
I have watched toooo many videos and I need help. This is my first time posting here so please help me.
I have a sheet that I have been using and I want to simplify some things. On the Main sheet, Everyday I input data and its color coded based on its status. I am on Row 5527 now and would love a VBA to select "Update Tracker" that would move the appropriate rows to the identified sheets. The second sheet as a table that I was trying to use with another youtube video and one part of the code will not take. Please help me......
↧
January 23, 2020, 1:21 pm
Hello experts. I am looking for a little clarity. I'm curious why an error 13 is thrown when setting the range.
Code:
Dim s As String: s = "temp"
Dim rng As Range
Set wb = ThisWorkbook
Set ws = wb.Sheets(s)
With ws
lrow = LastRow(ws) 'call function c. of de Bruin
ColNo = LastCol(ws) 'call function c. of de Bruin
ColLetter = Split(Cells(1, ColNo).Address, "$")(1)
Set rng = .Range("A1:" & ColLetter & lrow) 'vba allows a step through this
MsgBox rng.Address
Range(rng).sort key1:=Range("A1:A" & lrow), order1:=xlAscending, Header:=xlYes 'error 13 here....
End With
EDIT: MsgBox rng.Address says the range is set...I guess what the meat issue is the sort is not recognizing the declared range
↧
January 23, 2020, 1:32 pm
I am currently working on a file that performs various calculations using multiple functions.
There are 8600+ rows and it takes about 45 minutes for all of the calculations to execute. Is there a way to make this process faster?
An example file containing the code and several lines of data is attached.
↧
↧
January 23, 2020, 1:44 pm
Hello!
I am looking for a VBA that can recognize the Office365 account email address associated with the user who is opening it. For example, if I open it on my computer that has my office365 account logged into it, it will recognize that I am
joe@company.com - but if Bob opens it on his computer it will recognize that his office365 account is
bob@company.com.
The reason for doing this is that I want to be able to set parameters that the workbook will only show each user specified rows. Aka I only want Joe to see rows 4-10 so it hides all others when it recognizes that
joe@company.com is the one who opened the workbook.
It also needs to work for both macs & pcs - hence why I would like it to pull from the office365 account.
Any help is greatly appreciated!
↧
January 23, 2020, 1:45 pm
I'm having an issue where I would like to reference a column based on its header in one of the tables on my sheet, however because there is a '#' sign in the header name it is throwing me a 1004 error.
I've tried using a variable and chr(35) with no luck, does anyone have the solution to my issue?
Code:
set searchData = Range("MasterTable[# of Searches]")
The table is created from a connection and is then transfered to another sheet so renaming the column is not an optimal solution for me
↧
January 23, 2020, 2:15 pm
I have data in Workbook A and I need to copy one of the worksheets to the end of Workbook B. I need a macro in Workbook A that will:
Prompt the user for the file location for Workbook B.
Copy Worksheet1 from Workbook A to the newly opened Workbook B.
Find and Replace a text string (the embedded reference from Workbook A) and replace all with a blank.
** For clarification, when Workbook A is Copied to Workbook B it retains the original Workbook A name in the formulas. So I need to get rid of that reference and have the forumlas reference Workbook B. So I do a Find "WorkbookA.xlsx" and replace all with "".****
After the find and replace is complete, a dialog box will automatically pop and indicate the number of cells changed.
The caveat is sometimes the Workbook B is not shareable so the "Review/Share Workbook/"Allow Changes by more than one user" box has to be unchecked.
Thank you in advance!!
auballard
↧
January 23, 2020, 2:24 pm
Hello everyone!
I am having issues with a few of my public variables that are keeping the values of that were stored in them in the last run (Excel wasn't closed).
How do I reset the values, without having to do s_Test1 = "" for each string?
Here is an example, If I run this macro two times, it keeps the values form the first run and shows x2 values in the second run:
Code:
Option Explicit
Public s_Test1 As String
Public l_ForLoop1, l_LastRowCount1 As Long
Sub sb_Test1()
l_LastRowCount1 = Wks_Tmp2.Cells(Rows.Count, "A").End(xlUp).Row
For l_ForLoop1 = 1 to l_LastRowCount1
IF s_Test1 = "" Then
s_Test1 = Range("A" & l_ForLoop1).Value
Else
s_Test1 = s_Test1 & vbCrLf & Range("A" & l_ForLoop1).Value
End If
Next
Msgbox s_Test1
End Sub
↧
↧
January 23, 2020, 2:44 pm
I've been working on and developing an exported report via Excel and VBA and had originally set it up to be a monthly workbook. However, I need to make it more of a End of Week up to the last day of the month. Basically, I'm going to have monthly folders, and weekly workbooks. I fully know how to calculate End of week using...
Code:
WEdate = Format(Now() - Weekday(Now()) + 6, "mm-dd-yyyy")
and EOM by using...
Code:
Function GetNowLast() as Date
dYear = Year(Now)
dMonth = Month(Now)
getDate = DateSerial(dYear, dMonth + 1, 0)
GetNowLast = getDate
End Function
But what I am wanting do do is See if the end of the month is in that week, and before the end of the week. That way it stops that weeks workbook on the last day of the month.
Example would be how 12/31/2019 fell on Tuesday this year. So the last "week" workbook would end on Tuesday for December and the first "week" workbook of January would start on Wednesday. Any thoughts help on this issue will be appreciated. Thanks.
↧
January 23, 2020, 3:20 pm
Hi,
I have 10 listboxes in my userform and I can double click each listbox lines and populate information from there to 10 textboxes.
Im wondering if I can in Userform Intialize, once the userform opens that the information in listboxes be populated automatically to the textboxes.
I have a code below but doesn't do anything really just selects the first list but no double click
lstLookup.Value = Selection
For i = 1 To lstLookup.ListCount - 1
lstLookup.Selected(i) = True
Next I
End Sub
Thanks
Steve
↧
January 23, 2020, 3:59 pm
I have a large range of cells I need to define:
Code:
Dim D_KeyCells As Range
Dim E_KeyCells As Range
Dim G_KeyCells As Range
Dim I_KeyCells As Range
Dim J_KeyCells As Range
Dim K_KeyCells As Range
Dim L_KeyCells As Range
Dim M_KeyCells As Range
and then set the ranges (Witch are basically the same:
Code:
Set D_KeyCells = Range("D6:D16")
Set E_KeyCells = Range("E6:E16")
Set G_KeyCells = Range("G6:G16")
Set I_KeyCells = Range("I6:I16")
Set J_KeyCells = Range("J6:J16")
Set K_KeyCells = Range("K6:K16")
Set L_KeyCells = Range("L6:L16")
Set M_KeyCells = Range("M6:M16")
I was trying to simplify everything by doing the following (So the above code would not be needed)
I am using this code to grab the current cell column letter
Code:
C_C = Split(ActiveCell(1).Address(1, 0), "$")(0)
and I was trying to use some code like this to create the Range based on the column letter
Code:
CurrentRange = "Range(" & Chr(34) & C_C & "6:" & C_C & "16" & Chr(34) & ")"
but how can I change that into something I can then use for this:
Code:
If Not Application.Intersect(CurrentRange, Range(Target.Address)) Is Nothing Then
Call C_C & "_CheckRow" 'So it would be calling D_CheckRow, or E_Check_row, ect..
End If
↧
January 23, 2020, 4:23 pm
Hello,
I'm trying to figure out how to reference in a userform's code, the value of a range variable from Sheet1. I tried different approaches but this is out of my league.
I get the value from a cell on a table's column, upon double-clicking.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rng As Range
If Not Intersect(Target, Sheet1.ListObjects("ClientsTable").ListColumns("Destination").DataBodyRange) Is Nothing Then
Cancel = True
rng = Range(Target)
UserForm1.Show
End If
End Sub
I need the userform to capture the target range and place the form's input in that specific cell.
Any suggestion?
↧
↧
January 23, 2020, 5:59 pm
Hello all,
I want to copy data from sheet 1 to sheet 2 below the last used cell/row.
Attaching excel file for better understanding, I want the highlighted cells to go to sheet2 with M or VBA code. or if any other easy alternatives available.
↧
January 23, 2020, 6:03 pm
How do I get this running twice on a single sheet? This targets A1 to perform this function, but I also want the function to be performed if B1 is changed.
Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("A1")
If Range("AA1").Value = "1" Then
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
MsgBox "This is 1"
End If
End If
If Range("AA1").Value = "2" Then
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
MsgBox "This is 2"
End If
End If
End Sub
P.S. Obviously not that exact code - because a message box saying This is 1 would be ridiculous, I'm just trying to get this working before I build the rest of the code.
↧
January 24, 2020, 10:36 am
Dear Tram,
I am having problem on copy paste value on there sheet.
My code is
Code:
Dim actWsh As String
Dim sh As Worksheet, ws As Worksheet
Dim LstRw As Long, Frng As Range, c As Range
Dim lItem As Integer
Dim Index As String
Set ws = Sheets("Schedule")
actWsh = ComboBox2.Text
Set sh = Sheets("Topics")
With ws
LstRw = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
With .Range(.Cells(LstRw + 1, 1), .Cells(LstRw + 15, 1))
.Merge
.BorderAround , xlThin
End With
.Cells(LstRw + 1, 1) = CDate(Me.TextBox1.Value)
.Cells(LstRw + 1, 1).VerticalAlignment = xlCenter
.Cells(LstRw + 1, 1).HorizontalAlignment = xlCenter
End With
With ws
LstRw = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
With .Range(.Cells(LstRw + 1, 4), .Cells(LstRw + 15, 4))
.Merge
.BorderAround , xlThin
End With
.Cells(LstRw + 1, 4) = ComboBox2.Value
.Cells(LstRw + 1, 4).VerticalAlignment = xlCenter
.Cells(LstRw + 1, 4).HorizontalAlignment = xlCenter
End With
With ws
LstRw = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
With .Range(.Cells(LstRw + 1, 5), .Cells(LstRw + 15, 5))
.Merge
.BorderAround , xlThin
End With
.Cells(LstRw + 1, 5) = ComboBox3.Value
.Cells(LstRw + 1, 5).VerticalAlignment = xlCenter
.Cells(LstRw + 1, 5).HorizontalAlignment = xlCenter
End With
With ws
LstRw = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
With .Range(.Cells(LstRw + 1, 6), .Cells(LstRw + 15, 6))
.Merge
.BorderAround , xlThin
End With
.Cells(LstRw + 1, 6) = ComboBox4.Value
.Cells(LstRw + 1, 6).VerticalAlignment = xlCenter
.Cells(LstRw + 1, 6).HorizontalAlignment = xlCenter
End With
With ws
LstRw = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
With .Range(.Cells(LstRw + 1, 8), .Cells(LstRw + 15, 8))
.Merge
.BorderAround , xlThin
End With
.Cells(LstRw + 1, 8) = ComboBox5.Value
.Cells(LstRw + 1, 8).VerticalAlignment = xlCenter
.Cells(LstRw + 1, 8).HorizontalAlignment = xlCenter
End With
For lItem = 0 To UserForm3.ListBox1.ListCount - 1
If UserForm3.ListBox1.Selected(lItem) Then
If Index <> vbNullString Then Index = Index & " / "
Index = Index & UserForm3.ListBox1.List(lItem)
End If
With ws
LstRw = .Cells(.Rows.Count, "C").End(xlUp).Row + 1
With .Range(.Cells(LstRw + 1, 7), .Cells(LstRw + 15, 7))
.Merge
.BorderAround , xlThin
.WrapText = True
End With
.Cells(LstRw + 1, 7) = Index
.Cells(LstRw + 1, 7).VerticalAlignment = xlCenter
.Cells(LstRw + 1, 7).HorizontalAlignment = xlCenter
End With
Next
x = 1
With sh
Set Frng = .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
For Each c In Frng.Cells
If x < 16 Then
If .Cells(c.Row, "E") = Me.ComboBox3 And .Cells(c.Row, "C") = Me.ComboBox2 Then
If c.EntireRow.Hidden = False Then
.Range("A" & c.Row & ":B" & c.Row).Copy ws.Cells(LstRw + x, 2)
c.EntireRow.Hidden = True
x = x + 1
End If
End If
End If
Next c
End With
on my above code i am merging 15 nos of cell by default.
But i want to merge only according to values updated on column B & C.
can any one please help me
↧