Automatically Rename Worksheets - Character String Too Long
Jan 17, 2013
I have some code which looks through a logfile, and creates new worksheets based on items found in a particular column. This is normally working fine. However, there is a particular case where the item in the column is too long - it is actually the path name of a particular file, and which exceeds 31 characters.
This is causing an error in VBA. Is there a way that the worksheet can be renamed if the character string is too long?
I have a spreadsheet that has a column of text that is always 10 characters long. There are 10 rows of text so there could be 100 text characters if all rows are filled. The rows usually will not all be filled. There will probably be blank rows between used rows. I have been able to capture the text and put it into one cell as one long text which is ok but I want to be able to break it up into the 10 character strings again, separated with a comma and space between each 10 characters.
This is the code I used to collect the 10 character text strings and put them all together as the variable "result". I used & ", " after ... Cells(r,17) which worked fine unless there was a blank row. If the row was blank it put in a comma and space anyway so I ended up with duplicate(triplicate) commas and spaces.
Private Sub test_Click() result = "" For r = 5 To 32 Step 3 'If Cells(r, 17) "" Then result = result & Cells(r, 17) Next r Range("r5") = result End Sub
I'm trying to run a countif formula in a separate worksheet searching for a long text string. The text string is long enough that I can't copy the entire string into the Ctrl F Find function.
=COUNTIF('Data Month 1'!C:C,F4)
F4 = text string put together using the values of multiple adjascent cells. Total characters are over 26.
I have a very long string of characters inside one cell.
Now, I would like to divide this string into multiple rows and I know that next row should start after each 80 character. In other words, 81th character is a start of a new row.
I've got a string of text (that can vary in length) and contains a date (could be any month).. I'm trying to extract the date from the string using VBA.
For example, the string may be:
"The following price of the service is effective until July 1, 2012 and may change whenever"
I need to first determine if the string has a date in it and then extract the date....
I did a search on mrexcel.com and found the following formula that will tell me if the text has a date (returns true/false)...however, i'm not sure how to use this in VBA nor how to find location of date....
=SUMPRODUCT(COUNTIF(B1,"*"&N73:N84&"*"))>0
B1 contains the text, N1:N12 contain the name of the months....
I'm trying to use application.match() but I'm running into a issue where I don't know if I'll be matching a string or long data type...
Here's the snippet of code:
Code: ' UNIT DATA ' Set Unit# s1 = ActiveSheet.Pictures(Application.Caller).Name iLen = Len(s1) s1 = Mid(s1, 2, iLen - 2) ' Set Sel Ex Work Date iCheck = Application.Match("MACHINE_NUMBER", Sheets("Allocation").Columns(1), 0)
[code]....
How can I get application.match to look for strings if s1 = "ABC123" or numbers if s1 = "123456"
I've tried dim variant and s1 + 0... But, haven't come up with a solution.
I have a Userform (PictureViewer) with a.o. a combobox and a textbox on it. The combobox has a picturename with the full path, i.e. C:My DocumentsJohnMy PicsSummer VacationImg_0001.jpg. The textbox will have the replacement name for that picture entered in it while the picture is visible, i.e. Harry and Antoinette (no extension). Pictures get cycled on this Userform with a forward and backward button. When I click the forward button, the next picture opens up and the name of that picture replaces the previous name in the combobox. What I would like to do is on the click of a commandbutton, copy the string (full path) in the combobox to a column (A), starting at the first cell and in the column beside it (B) end up with the new picture name including the full path. In this case, that would be C:My DocumentsJohnMy PicsSummer VacationHarry and Antoinette.jpg. The next picture name I want to change would be in the cells below this. This could go on for many pictures. I have the macro to change the file names once when I have cycled through everything I want to change. Is it possible to do this in one click or do I have to split the drive name, all folder names and picture name, replace the picture name with the new name manually and concatenate it again? The depth of folders can vary of course. The macro for renaming is as follows
Sub RenameTheFiles() Dim OldName As String Dim NewName As String Dim LastRow As Long Dim I As Long LastRow = Range("A65536").End(xlUp).Row For I = 1 To LastRow OldName = Range("A" & I).Value NewName = Range("B" & I).Value Name OldName As NewName Next I End Sub
I have a workbook with multiple tabs. On sheet one a person chooses a date to initialise a formula. That date is then copied to sheet two and placed in cell D5. The date is projected out for two weeks and then the next fornight starts on sheet three and so on. The start date for each new fortnight appears in cell D5 of each sheet. I want that information to be the name of the tab for sheet two, three etc. I have put this code into the "This Workbook" section:
Private Sub Worksheet_Change(ByVal Target As Range)
' Renames all worksheet tabs with each worksheet's cell A1 contents. 'If cell A1 has no content, then that tab is not renamed.
For i = 1 To Sheets.Count If Worksheets(i).Range("$D$4").Value "" Then Sheets(i).Name = Worksheets(i).Range("$D$4").Value End If Next End Sub
I have also tried:
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$D$4" Then ActiveSheet.Name = Left(Target.Value, 10) End Sub
I then go back into sheet one and change the date and nothing happens. I seem to be missing something. Can anyone please help?
I received a request from a coworker regarding custom formatting some numbers in his spreadsheet. Those numbers are serial numbers of 20 characters long. Sometimes in my files I use this custom number formatting ###0 and its enough for the data I handle. But when I tried to use it in his spreadsheet, the following shows:
8456891070060510000
The cell must look like this: 08456891070060510302
The reason to have it like this is due to a Delivery Program requirement to deliver Set-top Units for repair. The Delivery Program do not recognize other format than the above. My coworker takes the data from a spreadsheet, and the spreadsheet needs a custom number format to display the correct number.
find a custom number format to be able to display as my coworker need it??
I have a google earth KML file that I have converted to text, and through a bunch of manipulation have been able to pull a series of GPS coordinate strings into a single cell string. Unfortunately, the string data is beyond what excel 2007 can handle for a single cell. so my thought is to have excel pull each coordinate string into a separate cell with which i can then run a macro to develop a new KML dynamically. (changing multiple attributes based on a query to a database)
Each string of coords actually maps out a single region (path) on the KML, truth be told it is telecom rate center data, and each rate center will have numerous other variables applied to it depending on my company's voice network capability for a given rate center. Currently my only desire is to depict differently any rate centers that I'm able to deliver VOIP services to by showing them in a different color...but these change very often so it will support to be able to auto generate the map from time to time.
the raw data from the KML looks like this:
Code:
CLINTONVL
RATE_CNTRCLINTONVL STATEPA]]>
ff000000 1 0 1
[Code] ..........
After doing my data import, i extracted via various manipulations, the rate center name (a common lookup value that stays constant across multiple databases), and the string of coordinates. this is where i run into trouble. i need to pull each coord into a separate cell assuming i won't run out of cells in the x coordinates to gather this data OR find a way to grab the data via another lookup to another document...not desireable.
First off, my import was jacked up by missing some comma's...this i can fix easily with the string importation and manipulation HOWEVER...i still run into the issue of string length OFTEN.
Im trying to get the SPECIAL NUMBER to rename the photos(Column C) according to their names(Column B) and tried using index and match but some of them are giving me errors..
I have created an appointment schedule spreadsheet. Once I get the spreadsheet running smoothly, I would like to create a worksheet for every day of the year that we are open.
I have decided to have one main folder with 26 subfolders in it. In each of those 26 subfolders, there will be one workbook with 12 worksheets in it. That will be two weeks worth of appointments as we are open Mon-Sat. Of course I want to name the worksheet tabs at the bottom of the workbook according to the appropriate calendar date. Then there is also a cell at the top of each page that also has the date, the same as the date on the tab. Just wondering if there is a simple way to create a macro to rename all these worksheet tabs, or if I have to physically open up each workbook, and rename all the worksheet tabs according to the calendar date. Then once the worksheet tab is named, can you make it automatically put the same date into Cell A1?
I have groups of folders that I need to extract "Sheet2" from each workbook and assemble them into one workbook. Along the way I want to rename the sheets to the file name (-xls). I have assembled this code so far but it is broken
Code:
Sub CombineSheets() Dim sPath As String Dim sFname As String Dim wBk As Workbook Dim wSht As Variant
I'm looking for some VBA code that would look at a column of data, look at each cell value in that column and if the cell value starts with the letter 'G' and the 5th character in that cell is not 'Z' or 'X' I would like to highlight that cell. Example:G123-123 would be highlighted whereas G123Z-123 would not.
I would like to get the nth character from a string. For example, let's say there is a string "jupiter", and I would like to get the 3rd character of this string, "p". Is there a function in excel vba that would allow me to do this?
I have this data and want to extract the character after the letter Y if the string has a Y in it.
Example data Output
AU 2013 OD ANR B24 Y2 2 AU 2013 OD ANR B24 Y4 4 AU 2013 OD ANR B24 Y5 5 AU 2013 PD HLD NOV B SPA AU 2013 PD HLD NOV C SPA AU2013OD ANR B25 Y1 1 AU2013OD ANU B25 Y5 5 AU2013OD WCR FPVN B49 AU2013OD Y6 FPVN B49 6 AU2013OD WCR FPVN B40 AU2013OD WCR FPVN B43
I have a web query that returns a city and state, but the last character of the state is lower case. I need VBA code to change the last char to upper case. Here is what I have so far:
I have a column that has various codes such as "E123" and "X456" and "S345". I just want to extract the numbers and leave the letters in each cell. How do you write a formula using the LEFT function to extract the last three numbers?
I have a cell that has approx 22000 characters. I'm trying to remove a specific character string from a cell by doing a find and replace with "". It works for characters in the first part of the cell but not for characters in the last part of the cell.
Example: I do a find/replace for the characters 21242 to "" in column A and I get the expected results. I do a find/replace on 69294 to "", again I get the expected results, but if I do a find/replace on 85203 to "", I get "Excel cannot find what I am searching for" (but its there!)
My cell size is within the max size of 32,767 characters so not sure why its not working.
I would like to find the position of the last occurrence of a character in a string. For example, I have a string with the following:
"c:wwgpeToolbidsTest File.GP$".
I would like to find out the position of the last '' in the string because I want to pull the filename, 'Test File.GP$' into a variable. I would like to avoid writing code to do this. Are there some Excel functions I can use for this?
I have a macro that asks the user to enter a file name and have written a small function to search the name given to the file to find any invalid characters, trouble is I must be doing something wrong as I doesn't work. Everytime I write something in the box I'm told it's invalid, regardless of weather it actually is or not.
I am trying to work out how to get nth position of a character in a string. For example in this
Code:
kjishdfiuayigdscka if I use the formula Code: =FIND("i",I$1),
it will give me answer 3. But I want the position of 3rd "i" in the string. The answer should be 12. How can I change this formula to get the correct result?