Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2017, 11:54 PM
mj8mj4 mj8mj4 is offline Excel format Windows 10 Excel format Office 2013
Novice
Excel format
 
Join Date: May 2017
Posts: 2
mj8mj4 is on a distinguished road
Default Excel format

hey guys

I have a list of 1000 IP address that I need to use them in python code but I need them in specific format like this

192.168.1.1
192.168.1.2
192.168.2.1


I need them like this :

'192.168.1.1','192.168.1.2','192.168.2.1'


basically I need this format '','',''


any Idea ?
Reply With Quote
  #2  
Old 05-12-2017, 12:04 AM
mj8mj4 mj8mj4 is offline Excel format Windows 10 Excel format Office 2013
Novice
Excel format
 
Join Date: May 2017
Posts: 2
mj8mj4 is on a distinguished road
Default

whats the steps or the formula ? please
Reply With Quote
  #3  
Old 05-12-2017, 08:33 AM
NoSparks NoSparks is offline Excel format Windows 7 64bit Excel format Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Don't know what you're actually working with or its layout so have assumed IP addresses are in column A of Sheet1 starting in A1 and write the result to C1.
Setup a sample test sheet for experimentation.
I suspect the C1 cell will contain more characters than Excel can display but you should be able to copy and paste the entire cell value provided it doesn't exceed 32,767 characters.
Code:
Sub reFormat()
    Dim lr As Long, i As Integer, str As String
    Dim arr As Variant

    lr = Cells(Rows.Count, "A").End(xlUp).Row
    arr = Sheets("Sheet1").Range(Cells(1, 1), Cells(lr, 1)).Value
    str = Chr(39)
    For i = LBound(arr) To UBound(arr)
        str = str & arr(i, 1) & Chr(39) & Chr(44) & Chr(39)
    Next i
    str = Left(str, Len(str) - 2)
    Range("C1").Value = str
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to Format a Table Column in Excel Sgt Rock Excel 0 02-14-2015 02:54 PM
Date format in excel vba LaercioNB Excel 3 08-09-2013 06:33 AM
Excel format excel 2010 to format a date jassie Excel 1 03-28-2013 02:33 AM
Need help in format or link in excel handsome1968 Excel 1 05-01-2010 09:20 AM
Excel format Format Excel to look like Word Kilconey Excel 1 04-30-2010 09:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft